New submission from Armin Rigo: The ``os`` functions generally accept any buffer-supporting object as file names, and interpret it as if ``bytes()`` had been called on it. However, ``os.listdir(x)`` uses the type of ``x`` to know if it should return a list of bytes or a list of unicodes---and the condition seems to be ``isinstance(x, bytes)``. So we get this kind of inconsistent behaviour:
>>> os.listdir(b".") [b'python', b'Include', b'python-config.py', ...] >>> os.listdir(bytearray(b".")) ['python', 'Include', 'python-config.py', ...] ---------- components: Library (Lib) messages: 297960 nosy: arigo priority: normal severity: normal status: open title: os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a list of unicodes type: behavior versions: Python 3.5, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30879> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com