GH-107465: Add pathlib.Path.from_uri() classmethod.#107640
GH-107465: Add pathlib.Path.from_uri() classmethod.#107640barneygale merged 13 commits intopython:mainfrom
pathlib.Path.from_uri() classmethod.#107640Conversation
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 |
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
Pathrather thanPurePathbecause it usesos.fsdecode(), and so its results vary from system to system. I intend to deprecatePurePath.as_uri()and move it toPathfor the same reason.pathlib.Path.from_uri()classmethod #107465📚 Documentation preview 📚: https://cpython-previews--107640.org.readthedocs.build/