https://github.com/python/cpython/commit/7d8725ac6f3304677d71dabdb7c184e98a62d864
commit: 7d8725ac6f3304677d71dabdb7c184e98a62d864
branch: main
author: Barney Gale <[email protected]>
committer: barneygale <[email protected]>
date: 2024-05-14T20:14:07Z
summary:

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.

files:
A Misc/NEWS.d/next/Library/2024-05-08-20-41-48.gh-issue-74033.YebHZj.rst
M Doc/whatsnew/3.14.rst
M Lib/pathlib/_local.py
M Lib/test/test_pathlib/test_pathlib.py

diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index 33a0f3e0f2f4bc..27c985bec104fe 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -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
diff --git a/Lib/pathlib/_local.py b/Lib/pathlib/_local.py
index 7dc071949b9bd7..011144a565540f 100644
--- a/Lib/pathlib/_local.py
+++ b/Lib/pathlib/_local.py
@@ -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
diff --git a/Lib/test/test_pathlib/test_pathlib.py 
b/Lib/test/test_pathlib/test_pathlib.py
index 4fd2aac4a62139..3df354eb25a58c 100644
--- a/Lib/test/test_pathlib/test_pathlib.py
+++ b/Lib/test/test_pathlib/test_pathlib.py
@@ -1108,8 +1108,8 @@ def test_is_mount_root(self):
         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
index 00000000000000..e6ff47e1a3e57b
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-05-08-20-41-48.gh-issue-74033.YebHZj.rst
@@ -0,0 +1 @@
+Drop support for passing keyword arguments to :class:`pathlib.Path`.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to