You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add pathlib.Path.from_uri() classmethod that creates a path objects from a 'file' URI, like file:///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 own as_uri() methods returning URIs like s3://, 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 a from_uri() classmethod, there is one clear and obvious method that subclasses may override.
Activity
pythonGH-107465: Add `pathlib.Path.from_uri()` classmethod.
pythonGH-107465: Add `pathlib.Path.from_uri()` classmethod.
Merge branch 'main' into pythongh-107465-pathlib-from-uri
Merge branch 'main' into pythongh-107465-pathlib-from-uri
Merge branch 'main' into pythongh-107465-pathlib-from-uri
GH-107465: Add `pathlib.Path.from_uri()` classmethod. (#107640)
barneygale commentedon Oct 1, 2023
Implemented in 3.13 / 15de493 / #107640
pythonGH-107465: Add `pathlib.Path.from_uri()` classmethod. (python#1…