gh-133875: Remove deprecated pathlib.PurePath.is_reserved (#133876)

This commit is contained in:
sobolevn 2025-07-19 20:07:46 +03:00 committed by GitHub
parent 7ae4749d06
commit 67036f1ee1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 15 additions and 36 deletions

View file

@ -45,7 +45,7 @@ Pending removal in Python 3.15
* :mod:`pathlib`: * :mod:`pathlib`:
* :meth:`.PurePath.is_reserved` * :meth:`!.PurePath.is_reserved`
has been deprecated since Python 3.13. has been deprecated since Python 3.13.
Use :func:`os.path.isreserved` to detect reserved paths on Windows. Use :func:`os.path.isreserved` to detect reserved paths on Windows.

View file

@ -542,20 +542,6 @@ Pure paths provide the following methods and properties:
Passing additional arguments is deprecated; if supplied, they are joined Passing additional arguments is deprecated; if supplied, they are joined
with *other*. with *other*.
.. method:: PurePath.is_reserved()
With :class:`PureWindowsPath`, return ``True`` if the path is considered
reserved under Windows, ``False`` otherwise. With :class:`PurePosixPath`,
``False`` is always returned.
.. versionchanged:: 3.13
Windows path names that contain a colon, or end with a dot or a space,
are considered reserved. UNC paths may be reserved.
.. deprecated-removed:: 3.13 3.15
This method is deprecated; use :func:`os.path.isreserved` to detect
reserved paths on Windows.
.. method:: PurePath.joinpath(*pathsegments) .. method:: PurePath.joinpath(*pathsegments)
Calling this method is equivalent to combining the path with each of Calling this method is equivalent to combining the path with each of

View file

@ -1917,7 +1917,7 @@ New Deprecations
* :mod:`pathlib`: * :mod:`pathlib`:
* Deprecate :meth:`.PurePath.is_reserved`, * Deprecate :meth:`!.PurePath.is_reserved`,
to be removed in Python 3.15. to be removed in Python 3.15.
Use :func:`os.path.isreserved` to detect reserved paths on Windows. Use :func:`os.path.isreserved` to detect reserved paths on Windows.
(Contributed by Barney Gale in :gh:`88569`.) (Contributed by Barney Gale in :gh:`88569`.)

View file

@ -373,6 +373,14 @@ http.server
(Contributed by Bénédikt Tran in :gh:`133810`.) (Contributed by Bénédikt Tran in :gh:`133810`.)
pathlib
-------
* Removed deprecated :meth:`!pathlib.PurePath.is_reserved`.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.
(Contributed by Nikita Sobolev in :gh:`133875`.)
platform platform
-------- --------
@ -482,6 +490,7 @@ Porting to Python 3.15
The |pythoncapi_compat_project| can be used to get most of these new The |pythoncapi_compat_project| can be used to get most of these new
functions on Python 3.14 and older. functions on Python 3.14 and older.
Deprecated C APIs Deprecated C APIs
----------------- -----------------

View file

@ -519,18 +519,6 @@ def is_absolute(self):
return False return False
return self.parser.isabs(self) return self.parser.isabs(self)
def is_reserved(self):
"""Return True if the path contains one of the special names reserved
by the system, if any."""
import warnings
msg = ("pathlib.PurePath.is_reserved() is deprecated and scheduled "
"for removal in Python 3.15. Use os.path.isreserved() to "
"detect reserved paths on Windows.")
warnings._deprecated("pathlib.PurePath.is_reserved", msg, remove=(3, 15))
if self.parser is ntpath:
return self.parser.isreserved(self)
return False
def as_uri(self): def as_uri(self):
"""Return the path as a URI.""" """Return the path as a URI."""
import warnings import warnings

View file

@ -539,12 +539,6 @@ def test_with_stem_empty(self):
self.assertRaises(ValueError, P('a/b').with_stem, '') self.assertRaises(ValueError, P('a/b').with_stem, '')
self.assertRaises(ValueError, P('a/b').with_stem, '.') self.assertRaises(ValueError, P('a/b').with_stem, '.')
def test_is_reserved_deprecated(self):
P = self.cls
p = P('a/b')
with self.assertWarns(DeprecationWarning):
p.is_reserved()
def test_full_match_case_sensitive(self): def test_full_match_case_sensitive(self):
P = self.cls P = self.cls
self.assertFalse(P('A.py').full_match('a.PY', case_sensitive=True)) self.assertFalse(P('A.py').full_match('a.PY', case_sensitive=True))

View file

@ -2741,7 +2741,7 @@ Fix deprecation of :data:`ssl.OP_NO_TLSv1_3`
.. nonce: TMWh1i .. nonce: TMWh1i
.. section: Library .. section: Library
:meth:`pathlib.PureWindowsPath.is_reserved` now identifies a greater range :meth:`!pathlib.PureWindowsPath.is_reserved` now identifies a greater range
of reserved filenames, including those with trailing spaces or colons. of reserved filenames, including those with trailing spaces or colons.
.. ..

View file

@ -1096,7 +1096,7 @@ Also changed its name and daemonic status, it can be now joined.
Add :func:`os.path.isreserved`, which identifies reserved pathnames such as Add :func:`os.path.isreserved`, which identifies reserved pathnames such as
"NUL", "AUX" and "CON". This function is only available on Windows. "NUL", "AUX" and "CON". This function is only available on Windows.
Deprecate :meth:`pathlib.PurePath.is_reserved`. Deprecate :meth:`!pathlib.PurePath.is_reserved`.
.. ..

View file

@ -0,0 +1,2 @@
Removed deprecated :meth:`!pathlib.PurePath.is_reserved`. Use
:func:`os.path.isreserved` to detect reserved paths on Windows.