[issue3187] os.listdir can return byte strings
Guido van Rossum
report at bugs.python.org
Thu Aug 21 18:17:46 CEST 2008
Guido van Rossum <guido at python.org> added the comment:
The proper work-around is for the app to pass bytes into os.listdir();
then it will return bytes. It would be nice if open() etc. accepted
bytes (as well as strings of course), at least on Unix, but not
absolutely necessary -- the app could also just know the right encoding.
I see two reasonable alternatives for what os.listdir() should return
when the input is a string and one of the filenames can't be decoded:
either omit it from the output list; or use errors='replace' in the
encoding. Failing the entire os.listdir() call is not acceptable, and
neither is returning a mixture of str and bytes instances.
----------
nosy: +gvanrossum
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3187>
_______________________________________
More information about the Python-bugs-list
mailing list