Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Pending removal in Python 3.15

* :mod:`pathlib`:

* :meth:`.PurePath.is_reserved`
* :meth:`!.PurePath.is_reserved`
has been deprecated since Python 3.13.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.

Expand Down
14 changes: 0 additions & 14 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,6 @@ Pure paths provide the following methods and properties:
Passing additional arguments is deprecated; if supplied, they are joined
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)

Calling this method is equivalent to combining the path with each of
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ New Deprecations

* :mod:`pathlib`:

* Deprecate :meth:`.PurePath.is_reserved`,
* Deprecate :meth:`!.PurePath.is_reserved`,
to be removed in Python 3.15.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.
(Contributed by Barney Gale in :gh:`88569`.)
Expand Down
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ Porting to Python 3.15

(Contributed by Serhiy Storchaka in :gh:`133595`.)

* 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`.)

Deprecated C APIs
-----------------

Expand Down
12 changes: 0 additions & 12 deletions Lib/pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,18 +518,6 @@ def is_absolute(self):
return False
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):
"""Return the path as a URI."""
import warnings
Expand Down
6 changes: 0 additions & 6 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '.')

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):
P = self.cls
self.assertFalse(P('A.py').full_match('a.PY', case_sensitive=True))
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.11.0a1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,7 @@ Fix deprecation of :data:`ssl.OP_NO_TLSv1_3`
.. nonce: TMWh1i
.. 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.

..
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.13.0a4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
"NUL", "AUX" and "CON". This function is only available on Windows.

Deprecate :meth:`pathlib.PurePath.is_reserved`.
Deprecate :meth:`!pathlib.PurePath.is_reserved`.

..

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed deprecated :meth:`!pathlib.PurePath.is_reserved`. Use
:func:`os.path.isreserved` to detect reserved paths on Windows.
Loading