Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Eryk Sun says: > It has to be a ValueError since the error is an invalid parameter at the > Python level. How does the first follow from the second? Strings with NULs in them aren't errors or invalid parameters at the Python level, and they are legal file names in at least some file systems. Jython does this: >>> import os >>> os.path.exists('/tmp/foo\0bar') False >>> os.stat('/tmp/foo\0bar') Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 2] No such file or directory: '/tmp/foo\x00bar' As far as I am concerned, raising ValueError is simply a bug. The documentation for the os module clearly states: All functions in this module raise OSError in the case of invalid or inaccessible file names and paths, or other arguments that have the correct type, but are not accepted by the operating system. I don't believe there is any good reason for singling out NULs for a different exception from other invalid file names like ">" on NTFS. This ought to be an OSError for functions like os.stat and False for os.path.exists, as Jython does. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33721> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com