Unicode error in wx_gdi ?

Discussion in 'Python' started by Erik Bethke, Mar 4, 2005.

  1. Erik  Bethke

    Erik Bethke Guest

    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, 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
     
    Erik Bethke, Mar 4, 2005
    #1
    1. Advertising

  2. Erik  Bethke

    Serge Orlov Guest

    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.
     
    Serge Orlov, Mar 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Mark Bram
    Replies:
    0
    Views:
    4,052
    Robert Mark Bram
    Sep 28, 2003
  2. ygao

    unicode wrap unicode object?

    ygao, Apr 8, 2006, in forum: Python
    Replies:
    6
    Views:
    591
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Apr 8, 2006
  3. Gabriele *darkbard* Farina

    Unicode digit to unicode string

    Gabriele *darkbard* Farina, May 16, 2006, in forum: Python
    Replies:
    2
    Views:
    564
    Gabriele *darkbard* Farina
    May 16, 2006
  4. gabor
    Replies:
    13
    Views:
    586
    Leo Kislov
    Nov 18, 2006
  5. Jean-Paul Calderone
    Replies:
    23
    Views:
    725
    Leo Kislov
    Nov 21, 2006
Loading...

Share This Page