-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path.from_uri()
doesn't work if the URI contains host component
#123599
Comments
Accepting a host component, other than It might be that UNC Windows file paths even further. I tested this on Windows and there this usage makes sense: >>> p = Path(r'\\host\path')
>>> print(p.as_uri())
file://host/path/
>>> p == Path.from_uri(p.as_uri())
True Perhaps |
All URIs with non-empty, non- path = Path.from_uri('file://server/share/foo.txt')
if path.as_posix().startswith('//'):
raise ValueError('Non-local file URI') We could add a |
Explicitly rejecting paths would certainly be better than returning invalid paths. Including |
This probably would anyway require special handling on Windows. On POSIX something like |
We should try to be consistent across OSs unless we really must diverge IMO.
Paths starting with two slashes are valid on both Windows and POSIX. On Windows they're UNC paths, whereas on POSIX they're implementation-defined (ref). |
It can be hard to be totally consistent across OSes. On Windows There's already other functionality in I should have used "incorrect" instead of "invalid" in my earlier comment. Although |
…()` on POSIX Raise `ValueError` in `pathlib.Path.from_uri()` if the given `file:` URI specifies a non-empty, non-`localhost` authority, and we're running on a platform without support for UNC paths.
Bug report
Bug description:
Path.from_uri()
introduced in Python 3.13 doesn't work properly if the URI contains a host component other thanlocalhost
. Following examples are run with Python 3.13 rc 1 on Linux with a machine having host namekone
:According to RFC 8089 including the host component as a fully qualified name is fine so this looks like a bug to me.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
pathlib.Path.from_uri()
on POSIX #123650The text was updated successfully, but these errors were encountered: