R. David Murray added the comment:

The issue of passing an fd is a fair point.

However, converting the filenames to bytes isn't going to help you print them, 
you'll just get decoding errors when converting them to strings instead of 
encoding errors.  You could use the surrogateescape error handler on stdout via 
PYTHONIONENCODING if you want to get the bytes out, but in that case you don't 
need to encode them to bytes yourself, your program can just handle them as 
strings and let the python IO machinery deal with the bytes.

If you really want bytes filenames from listdir with an fd, you can just apply 
os.fsencode to the results:  map(os.fsencode, listdir(fd))

So, I'm still -1 on this proposal.

(Note: there is an existing open issue about surrogateescape and subprocess 
binary streams, so that is a known problem we haven't solved yet, and 
represents a more general problem than this issue.)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27085>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to