[issue7669] test_unicode_file fails with non-ascii path
Ezio Melotti
report at bugs.python.org
Tue Jan 12 19:16:10 CET 2010
Ezio Melotti <ezio.melotti at gmail.com> added the comment:
This is because in "path = join(os.getcwd(), path)" os.getcwd() returns a non-ascii byte string and path is unicode, so the cwd is implicitly decoded with the ascii codec in join and the error is raised.
Using getcwdu() when the path is unicode seems to fix the problem:
def abspath(path):
"""Return an absolute path."""
if not isabs(path):
- path = join(os.getcwd(), path)
+ if isinstance(path, unicode):
+ path = join(os.getcwdu(), path)
+ else:
+ path = join(os.getcwd(), path)
return normpath(path)
----------
nosy: +ezio.melotti
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7669>
_______________________________________
More information about the Python-bugs-list
mailing list