-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Add pathlib.Path.from_uri()
classmethod
#107465
Labels
Comments
barneygale
added a commit
to barneygale/cpython
that referenced
this issue
Aug 4, 2023
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.
barneygale
added a commit
to barneygale/cpython
that referenced
this issue
Aug 4, 2023
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.
barneygale
added a commit
to barneygale/cpython
that referenced
this issue
Sep 2, 2023
barneygale
added a commit
to barneygale/cpython
that referenced
this issue
Sep 24, 2023
barneygale
added a commit
to barneygale/cpython
that referenced
this issue
Sep 30, 2023
barneygale
added a commit
that referenced
this issue
Oct 1, 2023
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>
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
…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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature or enhancement
Add
pathlib.Path.from_uri()
classmethod that creates a path objects from a 'file' URI, likefile:///c:/windows
. This method should accept RFC 8089file:
URIs, including variant forms.Pitch
The proposed method is the counterpart of
pathlib.Path.as_uri()
. As we continue to open up pathlib for subclassing, user subclasses of path classes will begin to appear with their ownas_uri()
methods returning URIs likes3://
,ftp://
. These subclasses will likely also support parsing URIs to create paths. However, there is currently no defined interface for doing this in pathlib, and users will be tempted to accept URIs in initialisers, which produces a confusing interface. If pathlib instead defines afrom_uri()
classmethod, there is one clear and obvious method that subclasses may override.Previous discussion
See https://discuss.python.org/t/make-pathlib-extensible/3428/136 and subsequent posts
Linked PRs
pathlib.Path.from_uri()
classmethod. #107640The text was updated successfully, but these errors were encountered: