]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46483: Remove `__class_getitem__` from `pathlib.PurePath` (GH-30848)
authorNikita Sobolev <mail@sobolevn.me>
Thu, 3 Feb 2022 09:25:10 +0000 (12:25 +0300)
committerGitHub <noreply@github.com>
Thu, 3 Feb 2022 09:25:10 +0000 (11:25 +0200)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Doc/whatsnew/3.11.rst
Lib/pathlib.py
Lib/test/test_pathlib.py
Misc/NEWS.d/next/Library/2022-01-23-11-17-48.bpo-46483.j7qwWb.rst [deleted file]
Misc/NEWS.d/next/Library/2022-01-24-13-00-09.bpo-46483.9XnmKp.rst [new file with mode: 0644]

index 33f39e5775269075e73ae1a938611db1340aa788..acb21d3ccaf17982455155c110eab1fe229a0037 100644 (file)
@@ -545,6 +545,9 @@ Removed
   Python 3.4 but has been broken since Python 3.7.
   (Contributed by Inada Naoki in :issue:`23882`.)
 
+* Remove ``__class_getitem__`` method from :class:`pathlib.PurePath`,
+  because it was not used and added by mistake in previous versions.
+  (Contributed by Nikita Sobolev in :issue:`46483`.)
 
 Porting to Python 3.11
 ======================
index 920e1f425a0c066f973c92939ea6c92c835fb671..7f4210e2b80c9be8ee5eaac837bf07d814993975 100644 (file)
@@ -12,7 +12,6 @@ from errno import ENOENT, ENOTDIR, EBADF, ELOOP
 from operator import attrgetter
 from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO
 from urllib.parse import quote_from_bytes as urlquote_from_bytes
-from types import GenericAlias
 
 
 __all__ = [
@@ -604,8 +603,6 @@ class PurePath(object):
             return NotImplemented
         return self._cparts >= other._cparts
 
-    __class_getitem__ = classmethod(GenericAlias)
-
     drive = property(attrgetter('_drv'),
                      doc="""The drive prefix (letter or UNC path), if any.""")
 
index 5e46b4ffeae1002d8e8e5087459d2b93a7f71e40..ec2baca18fd817535c154de154c1ad9280fe862d 100644 (file)
@@ -2450,15 +2450,6 @@ class _BasePathTest(object):
     def test_complex_symlinks_relative_dot_dot(self):
         self._check_complex_symlinks(os.path.join('dirA', '..'))
 
-    def test_class_getitem(self):
-        from types import GenericAlias
-
-        alias = self.cls[str]
-        self.assertIsInstance(alias, GenericAlias)
-        self.assertIs(alias.__origin__, self.cls)
-        self.assertEqual(alias.__args__, (str,))
-        self.assertEqual(alias.__parameters__, ())
-
 
 class PathTest(_BasePathTest, unittest.TestCase):
     cls = pathlib.Path
diff --git a/Misc/NEWS.d/next/Library/2022-01-23-11-17-48.bpo-46483.j7qwWb.rst b/Misc/NEWS.d/next/Library/2022-01-23-11-17-48.bpo-46483.j7qwWb.rst
deleted file mode 100644 (file)
index a84503d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Change :meth:`pathlib.PurePath.__class_getitem__` to return
-:class:`types.GenericAlias`.
diff --git a/Misc/NEWS.d/next/Library/2022-01-24-13-00-09.bpo-46483.9XnmKp.rst b/Misc/NEWS.d/next/Library/2022-01-24-13-00-09.bpo-46483.9XnmKp.rst
new file mode 100644 (file)
index 0000000..89cc818
--- /dev/null
@@ -0,0 +1 @@
+Remove :meth:`~object.__class_getitem__` from :class:`pathlib.PurePath` as this class was not supposed to be generic.