Demo crashing when in folder with accentuated letters

Hello,

I discover a problem with the wxPython demo. I can start the demo but
if I select a demo on the list it crash if the path to the demo folder
is containing accentuated characters.

I am on OpenSuse 11.2 x86_64 with Python 2.6.4 with wxPython 2.8.10.1.

It would be nice to add an unit test for that.

How can I report this bug properly?

Regards.

Pierre

Hi,

···

On Dec 22, 12:28 pm, pierreth <pierre.thibau...@gmail.com> wrote:

Hello,

I discover a problem with the wxPython demo. I can start the demo but
if I select a demo on the list it crash if the path to the demo folder
is containing accentuated characters.

I am on OpenSuse 11.2 x86_64 with Python 2.6.4 with wxPython 2.8.10.1.

It would be nice to add an unit test for that.

How can I report this bug properly?

Regards.

Pierre

Reporting a bug is easy! Just go to the wxPython website: http://wxpython.org/

Then click on the "Report a bug" link that's in the left column. Make
sure the bug hasn't already been reported first.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

PyCon 2010 Atlanta Feb 19-21 http://us.pycon.org/

Is it a hard crash or is there a traceback from an exception?

···

On 12/22/09 10:28 AM, pierreth wrote:

Hello,

I discover a problem with the wxPython demo. I can start the demo but
if I select a demo on the list it crash if the path to the demo folder
is containing accentuated characters.

--
Robin Dunn
Software Craftsman

Here the trace of my terminal:

Traceback (most recent call last):
  File "/home/pierreth/Téléchargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1835, in OnSelChanged
    self.LoadDemo(itemText)
  File "/home/pierreth/Téléchargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1857, in LoadDemo
    self.demoModules = DemoModules(demoName)
  File "/home/pierreth/Téléchargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1024, in __init__
    os.path.join(os.getcwd(), GetOriginalFilename(name))
  File "/usr/local/lib/python2.6/posixpath.py", line 70, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
16: ordinal not in range(128)

···

On 23 déc, 13:04, Robin Dunn <ro...@alldunn.com> wrote:

Is it a hard crash or is there a traceback from an exception?

-------------------------
Pierre

Seems the "Téléchargement“ part in the path caused it.

···

On Thu, Dec 24, 2009 at 10:25 AM, pierreth <pierre.thibault1@gmail.com> wrote:

On 23 déc, 13:04, Robin Dunn <ro...@alldunn.com> wrote:

Is it a hard crash or is there a traceback from an exception?

Here the trace of my terminal:

Traceback (most recent call last):
File "/home/pierreth/Téléchargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1835, in OnSelChanged
self.LoadDemo(itemText)
File "/home/pierreth/Téléchargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1857, in LoadDemo
self.demoModules = DemoModules(demoName)
File "/home/pierreth/Téléchargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1024, in __init__
os.path.join(os.getcwd(), GetOriginalFilename(name))
File "/usr/local/lib/python2.6/posixpath.py", line 70, in join
path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
16: ordinal not in range(128)

-------------------------
Pierre

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Pan, Xingzhi
http://www.panxingzhi.net

Hello,

I discover a problem with the wxPython demo. I can start the demo but
if I select a demo on the list it crash if the path to the demo folder
is containing accentuated characters.

I am on OpenSuse 11.2 x86_64 with Python 2.6.4 with wxPython 2.8.10.1.

No problem here, Windows 7, Py2.6.4, wxPy2.8.10.1-ansi.

I renamed the demo directory to "élève_wxPython2.8 Docs and Demos" and
tested
it with success in two ways
- "cd" to the demo.py directory and lauching it with a double click
- from a DOS terminal
C:\Users\Jean-Michel>c:\python26\python "C:\Program Files
\élève_wxPython2.8 Docs and Demos\demo\demo.py"

It would be nice to add an unit test for that.

How can I report this bug properly?

I would say this is not a wxPython issue, but rather a pure Python
issue.
This has been intensively discussed a few months ago on the Python dev-
list.
To be short, it has to do on how Python is interpreting command lines
args
and especially how it should especially interpret the encoding of the
args
on Linux systems (unicode normalization, posix, Python utf-8b internal
codec, ...)

Jean-Michel Fauth, Switzerland

···

On 22 déc, 19:28, pierreth <pierre.thibau...@gmail.com> wrote:

pierreth wrote:

  

Is it a hard crash or is there a traceback from an exception?

Here the trace of my terminal:

Traceback (most recent call last):
  File "/home/pierreth/T�l�chargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1835, in OnSelChanged
    self.LoadDemo(itemText)
  File "/home/pierreth/T�l�chargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1857, in LoadDemo
    self.demoModules = DemoModules(demoName)
  File "/home/pierreth/T�l�chargement/wxPython-src-2.8.10.1/wxPython/
demo/Main.py", line 1024, in __init__
    os.path.join(os.getcwd(), GetOriginalFilename(name))
  File "/usr/local/lib/python2.6/posixpath.py", line 70, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
16: ordinal not in range(128)

The problem is caused by the special character in your path name and you use the Unicode version of wxPython.

To fix it you can replace line 1024 in Main.Py:

            fileName = GetOriginalFilename(name).decode(sys.getfilesystemencoding())
            fPath = os.getcwd().decode(sys.getfilesystemencoding())
            self.modules[i][0]['__file__'] = os.path.join(fPath, fileName)

Does this fix still work with ANSI version of wxPython?

Werner

···

On 23 d�c, 13:04, Robin Dunn <ro...@alldunn.com> wrote:

The problem is caused by the special character in your path name and you
use the Unicode version of wxPython.

To fix it you can replace line 1024 in Main.Py:

        fileName =

GetOriginalFilename(name).decode(sys.getfilesystemencoding())
fPath = os.getcwd().decode(sys.getfilesystemencoding())
self.modules[i][0]['__file__'] = os.path.join(fPath, fileName)

Does this fix still work with ANSI version of wxPython?

Werner

Yes, it works (Windows7, Py2.6.4, wxPy2.8.10.1-ansi), I should
say I did not toy with all the modules.

I'm not deeply convinced the problem is coming from this.

jmf

What is Telechargement??

···

On Dec 25, 9:08 pm, Xingzhi Pan <vengeance.st...@gmail.com> wrote:

Seems the "Téléchargement“ part in the path caused it.

The demo has crashed for me too, even in recent versions, as well as
prior versions.
I don't remember which program I was using when it happened though.

···

On Dec 22, 10:28 am, pierreth <pierre.thibau...@gmail.com> wrote:

Hello,

I discover a problem with the wxPython demo. I can start the demo but
if I select a demo on the list it crash if the path to the demo folder
is containing accentuated characters.

I am on OpenSuse 11.2 x86_64 with Python 2.6.4 with wxPython 2.8.10.1.

It would be nice to add an unit test for that.

How can I report this bug properly?

Regards.

Pierre

I don't use the unicode version of wx- but the demo crashed anyway.
It's probably not the same issue. If I can duplicate it, I will file a
bug report.

···

On Dec 26, 1:28 am, werner <wbru...@free.fr> wrote:

pierreth wrote:
> On 23 d c, 13:04, Robin Dunn <ro...@alldunn.com> wrote:

>> Is it a hard crash or is there a traceback from an exception?

> Here the trace of my terminal:

> Traceback (most recent call last):
> File "/home/pierreth/T l chargement/wxPython-src-2.8.10.1/wxPython/
> demo/Main.py", line 1835, in OnSelChanged
> self.LoadDemo(itemText)
> File "/home/pierreth/T l chargement/wxPython-src-2.8.10.1/wxPython/
> demo/Main.py", line 1857, in LoadDemo
> self.demoModules = DemoModules(demoName)
> File "/home/pierreth/T l chargement/wxPython-src-2.8.10.1/wxPython/
> demo/Main.py", line 1024, in __init__
> os.path.join(os.getcwd(), GetOriginalFilename(name))
> File "/usr/local/lib/python2.6/posixpath.py", line 70, in join
> path += '/' + b
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 16: ordinal not in range(128)

The problem is caused by the special character in your path name and you
use the Unicode version of wxPython.

To fix it you can replace line 1024 in Main.Py:

        fileName =

GetOriginalFilename(name).decode(sys.getfilesystemencoding())
fPath = os.getcwd().decode(sys.getfilesystemencoding())
self.modules[i][0]['__file__'] = os.path.join(fPath, fileName)

Does this fix still work with ANSI version of wxPython?

Werner

Téléchargement (noun) is the French word for download.
Télécharger (verb) means to download.

I guess, Pierreth has downloaded the the wxPython demo and
has saved it in one of his /home directory called
Téléchargement.

After all, it's no a bad idea. The demo is a very good
*Python* application in its spirit. It can be downloaded
and unpack in the dir you wish.
It even run from a usb key.

jmf

···

On 26 déc, 19:20, cappy2112 <cappy2...@gmail.com> wrote:

On Dec 25, 9:08 pm, Xingzhi Pan <vengeance.st...@gmail.com> wrote:

> Seems the "Téléchargement“ part in the path caused it.

What is Telechargement??

To fix it you can replace line 1024 in Main.Py:

        fileName =

GetOriginalFilename(name).decode(sys.getfilesystemencoding())
fPath = os.getcwd().decode(sys.getfilesystemencoding())
self.modules[i][0]['__file__'] = os.path.join(fPath, fileName)

Does this fix still work with ANSI version of wxPython?

Werner

Reply #2

I think I have narrowed the issue. It has nothing
to do with the filesystem encoding, the error is coming from
the function os.path.join() which does not accept arguments
of different types (unicode and str).

On a Linux system with a utf-8 encoded filesystem, os.getcwd()
returns a unicode, while the module attribute __file__ is a str
type.

Your solution is probably working, not because you are decoding
according to the filesystemencoding, but just the fact you are
decoding, you create strings of the same type.

I can mimic this on Windows and get a similar error.

os.path.isfile(os.path.join('C:\jm\jmpy\junk\éàé', u'élève.txt'))

Traceback (most recent call last):
  File "<psi last command>", line 2, in <module>
  File "C:\Python26\lib\ntpath.py", line 108, in join
    path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
16: ordinal not in range(128)

os.path.isfile(os.path.join(u'C:\jm\jmpy\junk\éàé', 'élève.txt'))

Traceback (most recent call last):
  File "<psi last command>", line 2, in <module>
  File "C:\Python26\lib\ntpath.py", line 108, in join
    path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
1: ordinal not in range(128)

os.path.isfile(os.path.join('C:\jm\jmpy\junk\éàé', 'élève.txt'))

True

os.path.isfile(os.path.join(u'C:\jm\jmpy\junk\éàé', u'élève.txt'))

True

__file__

Traceback (most recent call last):
  File "<psi last command>", line 2, in <module>
NameError: name '__file__' is not defined

os.getcwd()

C:\jm\jmpy\psi\psi92beta3

type(os.getcwd())

<type 'str'>

It should also be noticed, the main() function of the module
demo.py changes the dir to the demo dir. Having to join
os.getwwd() and filenames of the demo modules in this dir
seems redundant.

Jean-Michel Fauth, Switzerland

Sharp observation.

I'm really looking forward to seeing wxPython running on Python 3+,
which is NOT backward compatible but has huge improvement in
Unicode/String handling. Previous Python implementation gives a lot
pain for people having to deal with non-ASCII strings often. I'm a
Chinese and I had enough of it... It's not that you can't work it out,
but you have to put that in mind every time...

···

On Sun, Dec 27, 2009 at 5:14 AM, jmfauth <wxjmfauth@gmail.com> wrote:

To fix it you can replace line 1024 in Main.Py:

        fileName =

GetOriginalFilename(name).decode(sys.getfilesystemencoding())
fPath = os.getcwd().decode(sys.getfilesystemencoding())
self.modules[i][0]['__file__'] = os.path.join(fPath, fileName)

Does this fix still work with ANSI version of wxPython?

Werner

Reply #2

I think I have narrowed the issue. It has nothing
to do with the filesystem encoding, the error is coming from
the function os.path.join() which does not accept arguments
of different types (unicode and str).

On a Linux system with a utf-8 encoded filesystem, os.getcwd()
returns a unicode, while the module attribute __file__ is a str
type.

Your solution is probably working, not because you are decoding
according to the filesystemencoding, but just the fact you are
decoding, you create strings of the same type.

I can mimic this on Windows and get a similar error.

os.path.isfile(os.path.join('C:\jm\jmpy\junk\éàé', u'élève.txt'))

Traceback (most recent call last):
File "<psi last command>", line 2, in <module>
File "C:\Python26\lib\ntpath.py", line 108, in join
path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
16: ordinal not in range(128)

os.path.isfile(os.path.join(u'C:\jm\jmpy\junk\éàé', 'élève.txt'))

Traceback (most recent call last):
File "<psi last command>", line 2, in <module>
File "C:\Python26\lib\ntpath.py", line 108, in join
path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
1: ordinal not in range(128)

os.path.isfile(os.path.join('C:\jm\jmpy\junk\éàé', 'élève.txt'))

True

os.path.isfile(os.path.join(u'C:\jm\jmpy\junk\éàé', u'élève.txt'))

True

__file__

Traceback (most recent call last):
File "<psi last command>", line 2, in <module>
NameError: name '__file__' is not defined

os.getcwd()

C:\jm\jmpy\psi\psi92beta3

type(os.getcwd())

<type 'str'>

It should also be noticed, the main() function of the module
demo.py changes the dir to the demo dir. Having to join
os.getwwd() and filenames of the demo modules in this dir
seems redundant.

Jean-Michel Fauth, Switzerland

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
http://www.panxingzhi.net

Hi Jean-Michel,

jmfauth wrote:

To fix it you can replace line 1024 in Main.Py:

            fileName =
GetOriginalFilename(name).decode(sys.getfilesystemencoding())
            fPath = os.getcwd().decode(sys.getfilesystemencoding())
            self.modules[i][0]['__file__'] = os.path.join(fPath, fileName)

Does this fix still work with ANSI version of wxPython?

Werner
    
Reply #2

I think I have narrowed the issue. It has nothing
to do with the filesystem encoding, the error is coming from
the function os.path.join() which does not accept arguments
of different types (unicode and str).

On a Linux system with a utf-8 encoded filesystem, os.getcwd()
returns a unicode, while the module attribute __file__ is a str
type.

Your solution is probably working, not because you are decoding
according to the filesystemencoding, but just the fact you are
decoding, you create strings of the same type.

I can mimic this on Windows and get a similar error.

os.path.isfile(os.path.join('C:\jm\jmpy\junk\���', u'�l�ve.txt'))
        

Traceback (most recent call last):
  File "<psi last command>", line 2, in <module>
  File "C:\Python26\lib\ntpath.py", line 108, in join
    path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
16: ordinal not in range(128)
  

os.path.isfile(os.path.join(u'C:\jm\jmpy\junk\���', '�l�ve.txt'))
        

Traceback (most recent call last):
  File "<psi last command>", line 2, in <module>
  File "C:\Python26\lib\ntpath.py", line 108, in join
    path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
1: ordinal not in range(128)
  

os.path.isfile(os.path.join('C:\jm\jmpy\junk\���', '�l�ve.txt'))
        

True
  

os.path.isfile(os.path.join(u'C:\jm\jmpy\junk\���', u'�l�ve.txt'))
        

True
  

__file__
        

Traceback (most recent call last):
  File "<psi last command>", line 2, in <module>
NameError: name '__file__' is not defined
  

os.getcwd()
        

C:\jm\jmpy\psi\psi92beta3
  

type(os.getcwd())
        

<type 'str'>
  

I am on Windows 7 with the following Python stuff.

# Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
# wxPython 2.8.10.1, Boa Constructor 0.6.1

···

#
You are write I don't need to decode the filename returned by GetOriginalFilename, but the path needs in my view to be decoded.

os.getcwd()
'C:\\Python25\\Lib\\site-packages\\boa'
>>> os.getcwd().decode(sys.getfilesystemencoding())
u'C:\\Python25\\Lib\\site-packages\\boa'

So the change should probably be:

            fileName = GetOriginalFilename(name)
            fPath = os.getcwd().decode(sys.getfilesystemencoding())
            self.modules[i][0]['__file__'] = os.path.join(fPath, fileName)

It should also be noticed, the main() function of the module
demo.py changes the dir to the demo dir. Having to join
os.getwwd() and filenames of the demo modules in this dir
seems redundant.
  

In which case one could just do this instead of the above three lines:

self.modules[i][0]['__file__'] = GetOriginalFilename(name)

Seems to work here, but no idea if this has some bad effect on some demos or on some systems, therefore I would just go for the first change.

Werner

Xingzhi Pan wrote:

Sharp observation.

I'm really looking forward to seeing wxPython running on Python 3+,
which is NOT backward compatible but has huge improvement in
Unicode/String handling. Previous Python implementation gives a lot
pain for people having to deal with non-ASCII strings often. I'm a
Chinese and I had enough of it... It's not that you can't work it out,
but you have to put that in mind every time...
  

Would not hold my breath while waiting for Py3x support, but then even if wxPython would support it there is still a lot of major libraries (in my view such as sqlalchemy, matplotlib, amara ...) out there which have not been updated, mainly because it is a lot of work for many of them.

I don't think the situation is that desperate with py 2.5.x and Unicode. I fell into the whole a few times when I converted from using the ascii version of wxPython to the Unicode version, one has to be careful when reading in stuff that one knows what its encoding is after that everything looks pretty transparent.

Werner

I don't think the situation is that desperate with py 2.5.x and
Unicode. I fell into the whole a few times when I converted from using
the ascii version of wxPython to the Unicode version, one has to be
careful when reading in stuff that one knows what its encoding is after
that everything looks pretty transparent.

Werner

No not desperate, but very annoying. And not only when dealing with
OS path. Strings and their binary representations should be separated
objects, connected by encode/decode. Then talk about transparency (-:

···

--
http://www.panxingzhi.net

So, what should I do? Change the code of the demo? How can I fix the
code and submit the changes I made so everyone will be able to enjoy
the fix?

Create a patch for it and either send it here or put it on wxTrac. A patch file is basically a diff from the original to your version. See wxTrac has been migrated to GitHub Issues - wxWidgets

···

On 12/29/09 1:25 AM, pierreth wrote:

So, what should I do? Change the code of the demo? How can I fix the
code and submit the changes I made so everyone will be able to enjoy
the fix?

--
Robin Dunn
Software Craftsman

Are you working with TDD (Test Driven Development)? If so, I would
have to write a test that fails first. Are the demo included with
wxPython having a set of unit tests?

···

On 29 déc, 14:52, Robin Dunn <ro...@alldunn.com> wrote:

Create a patch for it and either send it here or put it on wxTrac. A
patch file is basically a diff from the original to your version. Seehttp://trac.wxwidgets.org/wiki/HowToSubmitPatches

Pierre