STINNER Victor added the comment:

"What about bytearrays and other byte-like objects?

However I'm not sure this enhancement is worth to be accepted. Many other 
high-level functions in os and shutil modules do not support bytes paths. For 
shutil.which() there is no backward compatibility with Python 2 which we should 
support."

Bytes is the native type for path on all platforms... except Windows. So I 
fixed many functions of the os module to support bytes parameters. For example, 
functions of os.path support str and bytes types, but not bytearray. I also 
prefer to reject byte-like objects, to keep it simple.

The bytes type should be accepted for any kind of os function parameter: path, 
environment variable, command line argument, etc. It's not a question of being 
compatible with Python 2, an application can make the choice of only used bytes 
because bytes is the native type for OS data on UNIX.

Python 3 supports also "bytes stored in Unicode" thanks to the PEP 393, but 
it's not exactly the same: a path stored as str depends on the filesystem 
locale, whereas a bytes string is well defined (it's just an array of 8-bit 
unsigned numbers) and doesn't depend on any configuration variable.

----------

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

Reply via email to