STINNER Victor <victor.stin...@gmail.com> added the comment:

> 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."

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15441>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to