[issue3187] os.listdir can return byte strings

Antoine Pitrou report at bugs.python.org
Fri Oct 3 13:31:38 CEST 2008


Antoine Pitrou <pitrou at free.fr> added the comment:

> You should also support bytearray() in ntpath:
>    isinstance(path, (bytes, bytearray))

The most generic way of allowing all bytes-alike objects is to write:
    path = bytes(path)

It raises a TypeError if `path` can't export a read-only buffer of
contiguous bytes; also, it is a no-op if `path` is already a bytes
object, so very cheap in the common case.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3187>
_______________________________________


More information about the Python-bugs-list mailing list