Message319513
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. |
|
Date |
User |
Action |
Args |
2018-06-14 13:25:33 | steven.daprano | set | recipients:
+ steven.daprano, eric.smith, mrabarnett, r.david.murray, serhiy.storchaka, eryksun, pacujo |
2018-06-14 13:25:32 | steven.daprano | set | messageid: <1528982732.98.0.947875510639.issue33721@psf.upfronthosting.co.za> |
2018-06-14 13:25:32 | steven.daprano | link | issue33721 messages |
2018-06-14 13:25:32 | steven.daprano | create | |
|