One of the beauties of Python is that everything is an object, so one can easily replace a function with an another function, in code at run time. One doesn't need to edit the actual source code file (in part for precisely the reasons you are seeing here: it can break things for other people). So ideally that line 274 should be edited back to it's original:
self.__dict__['text'] = unicode(text)
Then your postdoc colleague could insert a code component in her experiment which creates an alternative version of that function in code, and swaps it out for the original one. This is known as 'monkey patching': the effect is only temporary, as it lasts only for the duration of the experiment (i.e. the actual source code file in text.py isn't being modified on disk, the change occurs in memory only).
i.e. in the
Begin experiment tab of the code component, she should create her alternative version of the function:
def my_text_function(self, text):
"""The text to be rendered. Use \\\\n to make new lines.
THIS IS AN ALTERNATIVE MONKEY PATCH VERSION TO DEAL WITH
SOME UNICODE STUFF.
Issues: May be slow, and pyglet has a memory leak when setting text.
For these reasons, check and only update the text if it has changed.
So scripts can safely set the text on every frame, no need to check.
if text == self.text:
if text != None: # make sure we have unicode object to render
self.__dict__['text'] = unicode(text, "utf-8") # *** THE ALTERED LINE ***
self._needSetText = False
# now replace the standard version of the function with the amended version.
# This should be *something* like this:
visual.text.TextStim.text = my_text_function
Of course, you might not be able to persuade your colleague to do the right thing, so you might need to do this process yourself, using the line without "utf-8" to temporarily undo the change she has made in the source code.