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 paul.moore
Recipients gaborjbernat, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-01-07.09:33:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610012037.67.0.505495940875.issue42855@roundup.psfhosted.org>
In-reply-to
Content
It's an invalid filename so it raises an exception.

You can get the same on Unix by using an invalid filename (embedded null):

>>> from pathlib import Path
>>> Path("/usr/\0").exists()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.7/pathlib.py", line 1356, in exists
    self.stat()
  File "/usr/lib64/python3.7/pathlib.py", line 1178, in stat
    return self._accessor.stat(self)
ValueError: embedded null byte

You need to be prepared for exceptions if you aren't sure you have a valid path. One thing that might be useful, I guess, is a `Path.is_valid()` function. But I don't know if all platforms have a way of asking the OS "is this a valid pathname?" So catching the exception is probably best.
History
Date User Action Args
2021-01-07 09:33:57paul.mooresetrecipients: + paul.moore, tim.golden, zach.ware, steve.dower, gaborjbernat
2021-01-07 09:33:57paul.mooresetmessageid: <1610012037.67.0.505495940875.issue42855@roundup.psfhosted.org>
2021-01-07 09:33:57paul.moorelinkissue42855 messages
2021-01-07 09:33:57paul.moorecreate