Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unicode error in wx_gdi ?

Reply
Thread Tools

Unicode error in wx_gdi ?

 
 
Erik Bethke
Guest
Posts: n/a
 
      03-04-2005
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(12

Granted this may seem like an obscure error, but the net effect is that
I cannot use wxPython for my games and applications as many of my users
will place the executable directly on their desktop and the path of the
desktop contains non-ascii paths.

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...

Any help would be much appreciated,
-Erik

 
Reply With Quote
 
 
 
 
Serge Orlov
Guest
Posts: n/a
 
      03-04-2005
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(12
>
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: os.lisdir, gets unicode, returns unicode... USUALLY?!?!? Jean-Paul Calderone Python 23 11-21-2006 10:25 AM
os.lisdir, gets unicode, returns unicode... USUALLY?!?!? gabor Python 13 11-18-2006 09:23 AM
Unicode digit to unicode string Gabriele *darkbard* Farina Python 2 05-16-2006 01:15 PM
unicode wrap unicode object? ygao Python 6 04-08-2006 09:54 AM
Unicode + jsp + mysql + tomcat = unicode still not displaying Robert Mark Bram Java 0 09-28-2003 05:37 AM



Advertisments