GH-123599: Deprecate duplicate pathname2url() implementation (#127380)

Call `urllib.request.pathname2url()` from `pathlib.Path.as_uri()`, and
deprecate the duplicate implementation in `PurePath`.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
Barney Gale 2025-03-20 00:54:36 +00:00 committed by GitHub
parent 6c776abb90
commit f141e8ec2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 45 additions and 19 deletions

View file

@ -886,9 +886,11 @@ conforming to :rfc:`8089`.
>>> p.as_uri()
'file:///c:/Windows'
For historical reasons, this method is also available from
:class:`PurePath` objects. However, its use of :func:`os.fsencode` makes
it strictly impure.
.. deprecated-removed:: 3.14 3.19
Calling this method from :class:`PurePath` rather than :class:`Path` is
possible but deprecated. The method's use of :func:`os.fsencode` makes
it strictly impure.
Expanding and resolving paths