10000 GH-74033: Drop deprecated `pathlib.Path()` keyword arguments · barneygale/cpython@2468f33 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2468f33

Browse files
committed
pythonGH-74033: Drop deprecated pathlib.Path() keyword arguments
Remove support for supplying keyword arguments to `pathlib.Path()`. This has been deprecated since Python 3.12.
1 parent aac6b01 commit 2468f33

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ Deprecated
101101
Removed
102102
=======
103103

104+
pathlib
105+
-------
106+
107+
* Remove support for passing additional keyword arguments to
108+
:class:`pathlib.Path`. In previous versions, any such arguments are ignored.
104109

105110

106111
Porting to Python 3.14

Lib/pathlib/_local.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os
55
import posixpath
66
import sys
7-
import warnings
87
from glob import _StringGlobber
98
from itertools import chain
109
from _collections_abc import Sequence
@@ -417,6 +416,7 @@ def is_absolute(self):
417416
def is_reserved(self):
418417
"""Return True if the path contains one of the special names reserved
419418
by the system, if any."""
419+
import warnings
420420
msg = ("pathlib.PurePath.is_reserved() is deprecated and scheduled "
421421
"for removal in Python 3.15. Use os.path.isreserved() to "
422422
"detect reserved paths on Windows.")
@@ -495,13 +495,6 @@ class Path(PathBase, PurePath):
495495
def _unsupported_msg(cls, attribute):
496496
return f"{cls.__name__}.{attribute} is unsupported on this system"
497497

498-
def __init__(self, *args, **kwargs):
499-
if kwargs:
500-
msg = ("support for supplying keyword arguments to pathlib.PurePath "
501-
"is deprecated and scheduled for removal in Python {remove}")
502-
warnings._deprecated("pathlib.PurePath(**kwargs)", msg, remove=(3, 14))
503-
super().__init__(*args)
504-
505498
def __new__(cls, *args, **kwargs):
506499
if cls is Path:
507500
cls = WindowsPath if os.name == 'nt' else PosixPath

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,10 +1121,6 @@ def test_is_mount_root(self):
11211121
self.assertTrue(R.is_mount())
11221122
self.assertFalse((R / '\udfff').is_mount())
11231123

1124-
def test_passing_kwargs_deprecated(self):
1125-
with self.assertWarns(DeprecationWarning):
1126-
self.cls(foo="bar")
1127-
11281124
def setUpWalk(self):
11291125
super().setUpWalk()
11301126
sub21_path= self.sub2_path / "SUB21"
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)
0