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

os.getcwdb() (GetCurrentDirectoryA) and os.listdir(bytes) (FindNextFileA & co) 
encode filenames using WideCharToMultiByte() in default mode (flags=0): 
unencodable characters are replaced by question marks. Such filenames cannot be 
used, open() fails with OSError(22, "invalid argument: '?'") for example.

Attached patch changes os.getcwdb() and os.listdir(bytes) to use the Windows 
native API (wide character API) with Python MBCS codec in strict mode (error 
handler "strict") to notify directly the user that the filename cannot be 
decoded.

The patch only changes the behaviour for filename not encodable to the ANSI 
code page, such filenames are rare.

----------
keywords: +patch
Added file: http://bugs.python.org/file23521/os_mbcs.patch

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

Reply via email to