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