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 pacujo
Recipients eric.smith, eryksun, mrabarnett, pacujo, r.david.murray, serhiy.storchaka, steven.daprano
Date 2018-06-14.22:50:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <877en1nfsp.fsf@elektro.pacujo.net>
In-reply-to <1529015754.3.0.947875510639.issue33721@psf.upfronthosting.co.za> (Eryk Sun's message of "Thu, 14 Jun 2018 22:35:54 +0000")
Content
Eryk Sun:
> 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.

For the original complaint of mine, catching ValueError would work. I
must say, though, that Steven's arguments for raising a fake OSError are
very convincing.

Steven D'Aprano:
> 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.

Now the question is not anymore if and how CPython should be fixed but
if and how Jython should be fixed.

IMO, Jython is doing the right thing. If that is not true, then Jython
must be declared buggy.

> 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.

Maybe. You'll still need OSError.errno to hold a true error value.

Marko
History
Date User Action Args
2018-06-14 22:50:48pacujosetrecipients: + pacujo, eric.smith, mrabarnett, steven.daprano, r.david.murray, serhiy.storchaka, eryksun
2018-06-14 22:50:48pacujolinkissue33721 messages
2018-06-14 22:50:48pacujocreate