Message166365
> If a file name was invalid byte character, os.chdir() raises
> UnicodeDecodeError() instead of WindowsError.
I realized that the problem is in the error handling: raising the OSError fails with a UnicodeDecodeError because PyErr_SetFromWindowsErrWithFilename() calls PyUnicode_DecodeFSDefault(), whereas the filename is not decodable. If you want to change something, it should be PyErr_SetFromWindowsErrWithFilename(). We may use PyObject_Repr() or PyObject_ASCII() for example.
--
See also the issue #13374: "The Windows bytes API has been deprecated in the os module. Use Unicode filenames instead of bytes filenames to not depend on the ANSI code page anymore and to support any filename." |
|
Date |
User |
Action |
Args |
2012-07-25 08:17:35 | vstinner | set | recipients:
+ vstinner, loewis, ishimoto, tim.golden, ezio.melotti |
2012-07-25 08:17:35 | vstinner | set | messageid: <1343204255.55.0.363445520738.issue15441@psf.upfronthosting.co.za> |
2012-07-25 08:17:34 | vstinner | link | issue15441 messages |
2012-07-25 08:17:34 | vstinner | create | |
|