Message191691
"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. |
|
Date |
User |
Action |
Args |
2013-06-23 11:42:32 | vstinner | set | recipients:
+ vstinner, tarek, Arfrever, hynek, serhiy.storchaka |
2013-06-23 11:42:32 | vstinner | set | messageid: <1371987752.39.0.670359506629.issue18283@psf.upfronthosting.co.za> |
2013-06-23 11:42:32 | vstinner | link | issue18283 messages |
2013-06-23 11:42:32 | vstinner | create | |
|