[Python-Dev] Emit a BytesWarning on bytes filenames on Windows
Victor Stinner
victor.stinner at haypocalc.com
Sat Oct 29 00:52:41 CEST 2011
Hi,
I am not more conviced that raising a UnicodeEncodeError on unencodable
characters is the right fix for the issue #13247. The problem with this
solution is that you have to wait until an user get a UnicodeEncodeError.
I have yet another proposition: emit a warning when a bytes filename is used.
So it doesn't affect the default behaviour, but you can use -Werror to test if
your program is fully Unicode compliant on Windows (without having to test
invalid filenames).
I don't know if a BytesWarning or a DeprecationWarning is more apropriate. It
depends if we plan to drop support of bytes filenames on Windows later (in
Python 3.5 or later).
List of impacted functions:
os._getfinalpathname(bytes)
os._getfullpathname(bytes)
os._isdir(bytes)
os.access(bytes)
os.chdir(bytes)
os.chmod(bytes)
os.getcwdb()
os.link(bytes, bytes)
os.listdir(bytes)
os.lstat(bytes)
os.mkdir(bytes)
os.readlink(bytes)
os.rename(bytes, bytes)
os.rmdir(bytes)
os.stat(bytes)
os.symlink(bytes, bytes)
os.unlink(bytes)
os.utime(bytes, time)
Note: Unicode filenames are not affected by this change. For example,
os.listdir(str) will not emit any warning.
Victor
More information about the Python-Dev
mailing list