Created
April 10, 2013 10:46
-
-
Save smathot/5353595 to your computer and use it in GitHub Desktop.
UnicodeError fix for _stimulus.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def __init__(self, log_comment=None): | |
| """Create a stimulus. | |
| Keyword arguments: | |
| log_comment -- the comment for the event log file (str) (optional) | |
| """ | |
| self._id = Stimulus._id_counter | |
| Stimulus._id_counter += 1 | |
| log_txt = "Stimulus,created,{0},{1}".format(self.id, | |
| self.__class__.__name__) | |
| if log_comment is not None: | |
| # Hack to avoid Unicode errors when Expyriment is placed in a | |
| # location that contains special characters. | |
| if isinstance(log_comment, str): | |
| import sys | |
| log_comment = log_comment.decode(sys.getfilesystemencoding()) | |
| log_txt = u"{0},{1}".format(log_txt, log_comment) | |
| expyriment._active_exp._event_file_log(log_txt, 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment