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

Merged
merged 4 commits into from
Jul 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
gh-133875: Remove deprecated pathlib.PurePath.is_reserved
  • Loading branch information
sobolevn committed May 11, 2025
commit 09b3e2425d98253a46efa94ea1e3b3982cb747b5
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
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
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