Erik Bethke wrote: > Hello All, > > I still shaking out my last few bugs in my tile matching game: > > I am now down to one stumper for me: > 1) when I initialize wxPython > 2) from an exe that I have created with py2exe > 3) when the executable is located on the desktop as opposed to > somewhere on C or D directly > 4) when My Desktop is not written in ascii but instead Korean hangul > > I get this error: > > Traceback (most recent call last): > File "shanghai.py", line 13, in ? > File "wxPython\__init__.pyc", line 10, in ? > File "wxPython\_wx.pyc", line 3, in ? > File "wxPython\_core.pyc", line 15, in ? > File "wx\__init__.pyc", line 42, in ? > File "wx\_core.pyc", line 10994, in ? > File "wx\_gdi.pyc", line 2443, in ? > File "wx\_gdi.pyc", line 2340, in Locale_AddCatalogLookupPathPrefix > UnicodeDecodeError: 'ascii' codec can't decode byte 0xbf in position > 26: ordinal not in range(128) > > Granted this may seem like an obscure error,
Thanks to your explanation, it doesn't look very obscure. I think the code in wxpython either uses sys.path[0] or __file__. Python still keeps byte strings in there because of backward compatibility. > What do i do from here? Do I go into wx_gdi.py and fix it so that it > uses unicode instead of ascii? I have not yet made any changes to > other people's libraries... You should contact wxpython people for proper cross platform fix, meanwhile you can fix that particular error on windows by changing sys.path[0] into sys.path[0].decode(sys.getfilesystemencoding()) or do the same thing for __file__. If there are a lot of similar problems, you can call sys.setdefaultencoding('mbcs') at the start of your program as last resort. Don't tell anyone I suggested that :) and remember that sys.setdefaultencoding is removed in site.py, changing default encoding can mask encoding bugs and make those bugs hard to trace. Serge. -- http://mail.python.org/mailman/listinfo/python-list