]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-74033: Drop deprecated `pathlib.Path` keyword arguments (#118793)
authorBarney Gale <barney.gale@gmail.com>
Tue, 14 May 2024 20:14:07 +0000 (21:14 +0100)
committerGitHub <noreply@github.com>
Tue, 14 May 2024 20:14:07 +0000 (20:14 +0000)
Remove support for supplying keyword arguments to `pathlib.Path()`. This
has been deprecated since Python 3.12.

Doc/whatsnew/3.14.rst
Lib/pathlib/_local.py
Lib/test/test_pathlib/test_pathlib.py
Misc/NEWS.d/next/Library/2024-05-08-20-41-48.gh-issue-74033.YebHZj.rst [new file with mode: 0644]

index 33a0f3e0f2f4bc9042b754c26d03dd238e0ec3b8..27c985bec104fe6d45396d456f54de16b55d7313 100644 (file)
@@ -131,6 +131,8 @@ itertools
 pathlib
 -------
 
+* Remove support for passing additional keyword arguments to
+  :class:`pathlib.Path`. In previous versions, any such arguments are ignored.
 * Remove support for passing additional positional arguments to
   :meth:`pathlib.PurePath.relative_to` and
   :meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such
index 7dc071949b9bd7cbbee1e86f4080952c8bde61b1..011144a565540f24a39cb5eac3cad078057c5082 100644 (file)
@@ -483,13 +483,6 @@ class Path(PathBase, PurePath):
     def _unsupported_msg(cls, attribute):
         return f"{cls.__name__}.{attribute} is unsupported on this system"
 
-    def __init__(self, *args, **kwargs):
-        if kwargs:
-            msg = ("support for supplying keyword arguments to pathlib.PurePath "
-                   "is deprecated and scheduled for removal in Python {remove}")
-            warnings._deprecated("pathlib.PurePath(**kwargs)", msg, remove=(3, 14))
-        super().__init__(*args)
-
     def __new__(cls, *args, **kwargs):
         if cls is Path:
             cls = WindowsPath if os.name == 'nt' else PosixPath
index 4fd2aac4a62139b67ec128f4b6d275dae61da705..3df354eb25a58c46525c14529635bbba9eee45b4 100644 (file)
@@ -1108,8 +1108,8 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
         self.assertTrue(R.is_mount())
         self.assertFalse((R / '\udfff').is_mount())
 
-    def test_passing_kwargs_deprecated(self):
-        with self.assertWarns(DeprecationWarning):
+    def test_passing_kwargs_errors(self):
+        with self.assertRaises(TypeError):
             self.cls(foo="bar")
 
     def setUpWalk(self):
diff --git a/Misc/NEWS.d/next/Library/2024-05-08-20-41-48.gh-issue-74033.YebHZj.rst b/Misc/NEWS.d/next/Library/2024-05-08-20-41-48.gh-issue-74033.YebHZj.rst
new file mode 100644 (file)
index 0000000..e6ff47e
--- /dev/null
@@ -0,0 +1 @@
+Drop support for passing keyword arguments to :class:`pathlib.Path`.