Here are 2 logs one with the default site.py forcing defaultencoding to ascii, and the other to utf8.
You can see that the home dir includes accents : Pépé Not an insult to anybody but this stupid computer :)
When I force using the locale.getdefaultlocale() as encoding then the function works, but, after having called expanduser, I need to make an explicit decode(locale.getdefaultlocale()), or else the string can not be used to build path to files.
==> with ASCII
C:\Users\pépé>D:\DevelopmentWorkspaces\SCOLASYNC\ScolaSyncNG\scolasync-ng\src\scolasync.py
Traceback (most recent call last):
File "D:\DevelopmentWorkspaces\SCOLASYNC\ScolaSyncNG\scolasync-ng\src\scolasync.py", line 329, in <module>
run()
File "D:\DevelopmentWorkspaces\SCOLASYNC\ScolaSyncNG\scolasync-ng\src\scolasync.py", line 206, in run
globaldef.initDefs(wd, force)
File "D:\DevelopmentWorkspaces\SCOLASYNC\ScolaSyncNG\scolasync-ng\src\globaldef.py", line 80, in initDefs
wrkdir= os.path.expanduser(u"~"+os.sep)
File "C:\Python27\lib\ntpath.py", line 301, in expanduser
return userhome + path[i:]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 10: ordinal not in range(128)
WITH UTF8 :
C:\Users\pépé>D:\DevelopmentWorkspaces\SCOLASYNC\ScolaSyncNG\scolasync-ng\src\scolasync.py
Traceback (most recent call last):
File "D:\DevelopmentWorkspaces\SCOLASYNC\ScolaSyncNG\scolasync-ng\src\scolasync.py", line 329, in <module>
run()
File "D:\DevelopmentWorkspaces\SCOLASYNC\ScolaSyncNG\scolasync-ng\src\scolasync.py", line 206, in run
globaldef.initDefs(wd, force)
File "D:\DevelopmentWorkspaces\SCOLASYNC\ScolaSyncNG\scolasync-ng\src\globaldef.py", line 80, in initDefs
wrkdir= os.path.expanduser(u"~"+os.sep)
File "C:\Python27\lib\ntpath.py", line 301, in expanduser
return userhome + path[i:]
File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 10: invalid continuation byte
|