Martin v. Löwis <mar...@v.loewis.de> added the comment: > 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).
Ok. Then I'm -1 on the patch: you can't know whether the application actually wants to open the file. Perhaps it only wants to display the file names, or perhaps it only wants to open some of the files, or only traverse into subdirectories. For backwards compatibility, I recommend to leave things as they are. FindFirst/NextFileA will also do some other interesting conversions, such as the best-fit conversion (which the "mbcs" code doesn't do (anymore?)). Windows has explicit A and W versions, and Python has explicit A and W types, so it's IMO best to pair them in the natural way (even if that means code duplication). > 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. Only if people run into the issue (which few people will). People which *do* run into the issue will likely get an error either way, which will teach them their lesson :-) ---------- title: Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames -> Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9820> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com