]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-107465: Add `pathlib.Path.from_uri()` classmethod. (#107640)
authorBarney Gale <barney.gale@gmail.com>
Sun, 1 Oct 2023 15:14:02 +0000 (16:14 +0100)
committerGitHub <noreply@github.com>
Sun, 1 Oct 2023 15:14:02 +0000 (16:14 +0100)
commit15de493395c3251b8b82063bbe22a379792b9404
tree15ab6a3a86eb413ea6c2c708dda48e4384f07f16
parent06faa9a39bd93c5e7999d52b52043ecdd0774dac
GH-107465: Add `pathlib.Path.from_uri()` classmethod. (#107640)

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>
Doc/library/pathlib.rst
Doc/whatsnew/3.13.rst
Lib/pathlib.py
Lib/test/test_pathlib.py
Misc/NEWS.d/next/Library/2023-08-04-19-00-53.gh-issue-107465.Vc1Il3.rst [new file with mode: 0644]