[Python-Dev] Windows: Remove support of bytes filenames in the os module?

Victor Stinner victor.stinner at gmail.com
Tue Feb 9 04:21:11 EST 2016


2016-02-09 1:37 GMT+01:00 eryk sun <eryksun at gmail.com>:
> For example, in codepage 932 (Japanese), it's an error if a lead byte
> (i.e. 0x81-0x9F, 0xE0-0xFC) is followed by a trailing byte with a
> value less than 0x40 (note that ASCII 0-9 is 0x30-0x39, so this is not
> uncommon). In this case the ANSI API substitutes the default character
> for Japanese, '・' (U+30FB, Katakana middle dot).
>
>     >>> locale.getpreferredencoding()
>     'cp932'
>     >>> open(b'\xe05', 'w').close()
>     >>> os.listdir('.')
>     ['・']
>     >>> os.listdir(b'.')
>     [b'\x81E']

Hum, I'm not sure that I understand your example. Can you pass the
result of os.listdir(str) to open() on Python 3? Are you able to open
the file? Same question for os.listdir(bytes).

Victor


More information about the Python-Dev mailing list