[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

STINNER Victor report at bugs.python.org
Sun Sep 12 18:18:49 CEST 2010

STINNER Victor <victor.stinner at haypocalc.com> added the comment:

> What do you gain with this patch? (i.e. what is its advantage?)

You know directly that os.listdir(bytes) is unable to encode the filename, instead of manipulate an invalid filename (b'?') and get the error later (when you use the filename: open, copy, delete, ... the file).

It's the same idea than str+bytes raises an error on Python3: get the error earlier instead of store invalid data and get the error to late.

Anywy, on Windows, it's not a good idea to manipulate bytes filenames. So it's also a way to encourage people to migrate their applications to unicode on Windows.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list