[issue13247] os.path.abspath returns unicode paths as question marks

STINNER Victor report at bugs.python.org
Tue Oct 25 21:51:30 CEST 2011


STINNER Victor <victor.stinner at 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 <report at bugs.python.org>
<http://bugs.python.org/issue13247>
_______________________________________


More information about the Python-bugs-list mailing list