This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年01月10日 18:18 by flox, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg97537 - (view) | Author: Florent Xicluna (flox) * (Python committer) | Date: 2010年01月10日 18:18 | |
/tmp/py2u...→unicode $ ./python Lib/test/regrtest.py test_unicode_file test_unicode_file test test_unicode_file failed -- Traceback (most recent call last): File "/tmp/py2u...→unicode/Lib/test/test_unicode_file.py", line 173, in test_single_files self._test_single(TESTFN_UNICODE) File "/tmp/py2u...→unicode/Lib/test/test_unicode_file.py", line 147, in _test_single self._do_single(filename) File "/tmp/py2u...→unicode/Lib/test/test_unicode_file.py", line 48, in _do_single self.assertTrue(os.path.exists(os.path.abspath(filename))) File "/tmp/py2u...→unicode/Lib/posixpath.py", line 338, in abspath path = join(os.getcwd(), path) File "/tmp/py2u...→unicode/Lib/posixpath.py", line 70, in join path += '/' + b UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 29: ordinal not in range(128) 1 test failed: test_unicode_file |
|||
| msg97642 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2010年01月12日 18:16 | |
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) |
|||
| msg97646 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2010年01月12日 18:31 | |
See #3426. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:56 | admin | set | github: 51918 |
| 2010年01月12日 18:31:58 | ezio.melotti | set | status: open -> closed priority: normal messages: + msg97646 resolution: duplicate stage: resolved |
| 2010年01月12日 18:30:57 | ezio.melotti | link | issue3426 superseder |
| 2010年01月12日 18:16:08 | ezio.melotti | set | nosy:
+ ezio.melotti messages: + msg97642 |
| 2010年01月10日 18:18:26 | flox | create | |