-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
GH-107465: Add pathlib.Path.from_uri()
classmethod.
#107640
GH-107465: Add pathlib.Path.from_uri()
classmethod.
#107640
Conversation
This method supports file URIs (including variants) as described in RFC 8089, such as URIs generated by `pathlib.Path.as_uri()` and `urllib.request.pathname2url`. The method is added to `Path` rather than `PurePath` because it uses `os.fsdecode()`, and so its results vary from system to system. I intend to deprecate `PurePath.as_uri()` and move it to `Path` for the same reason.
Thanks for your feedback, both. I've revised the code: We could add a non-strict mode, but I think that's best done in a separate PR that also considers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
A
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Thank you for the reviews, Adam, Andreas and Edgar! |
|
|
|
…07640) This method supports file URIs (including variants) as described in RFC 8089, such as URIs generated by `pathlib.Path.as_uri()` and `urllib.request.pathname2url()`. The method is added to `Path` rather than `PurePath` because it uses `os.fsdecode()`, and so its results vary from system to system. I intend to deprecate `PurePath.as_uri()` and move it to `Path` for the same reason. Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This method supports file URIs (including variants) as described in RFC 8089, such as URIs generated by
pathlib.Path.as_uri()
andurllib.request.pathname2url()
.The method is added to
Path
rather thanPurePath
because it usesos.fsdecode()
, and so its results vary from system to system. I intend to deprecatePurePath.as_uri()
and move it toPath
for the same reason.pathlib.Path.from_uri()
classmethod #107465📚 Documentation preview 📚: https://cpython-previews--107640.org.readthedocs.build/