diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst index a76d06cce1278a..0560c22f5bfd03 100644 --- a/Doc/deprecations/pending-removal-in-3.15.rst +++ b/Doc/deprecations/pending-removal-in-3.15.rst @@ -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. diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 47986a2d9602ee..ebf5756146df92 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -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 diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index ef7c36d8539dfd..6d5760192aa9a4 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -1917,7 +1917,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`.) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 9f327cf904da1b..f04601e8d100e8 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -324,6 +324,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 ----------------- diff --git a/Lib/pathlib/__init__.py b/Lib/pathlib/__init__.py index 2dc1f7f7126063..fd073445e89b62 100644 --- a/Lib/pathlib/__init__.py +++ b/Lib/pathlib/__init__.py @@ -519,18 +519,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 diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index b2e2cdb3338beb..16d30e3ca2d17d 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -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)) diff --git a/Misc/NEWS.d/3.11.0a1.rst b/Misc/NEWS.d/3.11.0a1.rst index 0b49c2a78771d2..2c8e349d3c8bfb 100644 --- a/Misc/NEWS.d/3.11.0a1.rst +++ b/Misc/NEWS.d/3.11.0a1.rst @@ -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. .. diff --git a/Misc/NEWS.d/3.13.0a4.rst b/Misc/NEWS.d/3.13.0a4.rst index 1b971113173e0a..8afbe1b77f7cb8 100644 --- a/Misc/NEWS.d/3.13.0a4.rst +++ b/Misc/NEWS.d/3.13.0a4.rst @@ -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`. .. diff --git a/Misc/NEWS.d/next/Library/2025-05-11-11-39-05.gh-issue-133875.pUar3l.rst b/Misc/NEWS.d/next/Library/2025-05-11-11-39-05.gh-issue-133875.pUar3l.rst new file mode 100644 index 00000000000000..b4a2b0336370bc --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-05-11-11-39-05.gh-issue-133875.pUar3l.rst @@ -0,0 +1,2 @@ +Removed deprecated :meth:`!pathlib.PurePath.is_reserved`. Use +:func:`os.path.isreserved` to detect reserved paths on Windows.