GH-107465: Add `pathlib.Path.from_uri()` classmethod. by barneygale · Pull Request #107640 · python/cpython

@barneygale

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.

@bedevere-bot mentioned this pull request

Aug 4, 2023

@barneygale

@barneygale

@barneygale

ap--

@ap-- ap-- mentioned this pull request

Aug 28, 2023

@barneygale

@barneygale

@ap-- ap-- mentioned this pull request

Sep 3, 2023

@barneygale

edgarrmondragon

@barneygale

@barneygale

AA-Turner

@barneygale

@barneygale

AA-Turner

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>

@barneygale

Glyphack pushed a commit to Glyphack/cpython that referenced this pull request

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>