This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eric.smith, eryksun, mrabarnett, pacujo, r.david.murray, serhiy.storchaka, steven.daprano
Date 2018-06-14.22:35:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1529015754.3.0.947875510639.issue33721@psf.upfronthosting.co.za>
In-reply-to
Content
>> 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?

I only meant that, as an honest error, it has to be ValueError. I didn't think about raising a fake OSError.

Note that I didn't say the ValueError shouldn't be ignored by os.path.exists (et al). In the spirit of the current function, it probably should be ignored. For example, it returns False for paths that exist but are inaccessible. 

> 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 can't pass a string that contains NUL characters to POSIX and Windows APIs that use null-terminated strings. That would yield wildly unpredictable results. We need this to be a reliable error. So for the low-level file I/O functions to return an OSError here, it would have to be a bit of a lie (i.e. an 'OS' error without making a system call and without an `errno` and/or `winerror` value). Maybe it could raise an InvalidFilename subclass of OSError. This could even handle some actual OS errors such as POSIX ENAMETOOLONG and Windows ERROR_INVALID_NAME, ERROR_BAD_PATHNAME, and ERROR_FILENAME_EXCED_RANGE.
History
Date User Action Args
2018-06-14 22:35:54eryksunsetrecipients: + eryksun, eric.smith, mrabarnett, steven.daprano, r.david.murray, serhiy.storchaka, pacujo
2018-06-14 22:35:54eryksunsetmessageid: <1529015754.3.0.947875510639.issue33721@psf.upfronthosting.co.za>
2018-06-14 22:35:54eryksunlinkissue33721 messages
2018-06-14 22:35:54eryksuncreate