Skip to content

Commit 7d8725a

Browse files
authored
GH-74033: Drop deprecated pathlib.Path keyword arguments (#118793)
Remove support for supplying keyword arguments to `pathlib.Path()`. This has been deprecated since Python 3.12.
1 parent fbe6a09 commit 7d8725a

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ itertools
131131
pathlib
132132
-------
133133

134+
* Remove support for passing additional keyword arguments to
135+
:class:`pathlib.Path`. In previous versions, any such arguments are ignored.
134136
* Remove support for passing additional positional arguments to
135137
:meth:`pathlib.PurePath.relative_to` and
136138
:meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such

Lib/pathlib/_local.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,6 @@ class Path(PathBase, PurePath):
483483
def _unsupported_msg(cls, attribute):
484484
return f"{cls.__name__}.{attribute} is unsupported on this system"
485485

486-
def __init__(self, *args, **kwargs):
487-
if kwargs:
488-
msg = ("support for supplying keyword arguments to pathlib.PurePath "
489-
"is deprecated and scheduled for removal in Python {remove}")
490-
warnings._deprecated("pathlib.PurePath(**kwargs)", msg, remove=(3, 14))
491-
super().__init__(*args)
492-
493486
def __new__(cls, *args, **kwargs):
494487
if cls is Path:
495488
cls = WindowsPath if os.name == 'nt' else PosixPath

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,8 @@ def test_is_mount_root(self):
11081108
self.assertTrue(R.is_mount())
11091109
self.assertFalse((R / '\udfff').is_mount())
11101110

1111-
def test_passing_kwargs_deprecated(self):
1112-
with self.assertWarns(DeprecationWarning):
1111+
def test_passing_kwargs_errors(self):
1112+
with self.assertRaises(TypeError):
11131113
self.cls(foo="bar")
11141114

11151115
def setUpWalk(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Drop support for passing keyword arguments to :class:`pathlib.Path`.

0 commit comments

Comments
 (0)