UnicodeEncodeError in mainframe.py for non-ascii characters #29

Open
bf4 opened this Issue Nov 9, 2011 · 9 comments

Comments

Projects
None yet
2 participants

bf4 commented Nov 9, 2011

e.g. from the log

self.statusBar().showMessage(self._("Joining room {room}...").format(room=room["name"]))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xeb' in position 1: ordinal not in range(128)

this results in not being able to perform most actions in the room. It does display the room name properly in the select box, so I'm not sure what's different about these methods. In any case, the room is not currently useable. I tried adding .encode("ascii", "ignore") in various places as a hack but didn't find them all.

@ghost ghost assigned mariano Nov 9, 2011

Owner

mariano commented Nov 9, 2011

Could you give me the gave of the failing room so I can replicate?

bf4 commented Nov 9, 2011

Nërd Lounge™

Owner

mariano commented Nov 9, 2011

Weird, I created a room with that exact name, and I'm able to join it correctly. There is an issue with the status bar (I don't see the warning you see, but the room name is not properly shown when displaying the Joining room message). I'm fixing that issue

@mariano mariano closed this in cdecdfe Nov 9, 2011

Owner

mariano commented Nov 9, 2011

Try with the recent update (you have to pull from the GIT repo, since I haven't yet released packages for this)

bf4 commented Nov 9, 2011

Will do tonight. thanks

bf4 commented Nov 11, 2011

hmm, that didn't appear to fix it...
$HOME/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/snakefire-1.0.4-py2.7.egg/snakefire/mainframe.py", line 335, in joinRoom
self.statusBar().showMessage(unicode(self._("Joining room {room}...").format(room=room["name"])))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xeb' in position 1: ordinal not in range(128)

bf4 commented Nov 11, 2011

(I'm on OSX snowleopard FWIW)

bf4 commented Nov 11, 2011

It looks like something to do with how .format is called and what the interpolation expects. I don't really know python, but from reading it about it, it appears the django module smart_str https://code.djangoproject.com/browser/django/tags/releases/1.1.1/django/utils/encoding.py#L95 would help or maybe adding !r to the interpolated string, or see http://docs.python.org/tutorial/introduction.html e.g. u'Hello\u0020World !'
u'Hello World !'

@mariano mariano reopened this Nov 13, 2011

Owner

mariano commented May 20, 2013

A related fix in #67 may have solved this. Could you test with latest git version? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment