summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2020-07-05 05:07:43 (GMT)
committerGitHub <noreply@github.com>2020-07-05 05:07:43 (GMT)
commit7fed75597fac11f9a6c769e2b6c6548fe0e4049d (patch)
tree0fe94b8d0df267975902c7eaa0282c223ef8fd27
parent9c8441712230660fedac818ed50e7cdd89e4c51d (diff)
downloadcpython-7fed75597fac11f9a6c769e2b6c6548fe0e4049d.zip
cpython-7fed75597fac11f9a6c769e2b6c6548fe0e4049d.tar.gz
cpython-7fed75597fac11f9a6c769e2b6c6548fe0e4049d.tar.bz2
bpo-39168: Remove the __new__ method of typing.Generic (GH-21327)
Automerge-Triggered-By: @gvanrossum
-rw-r--r--Lib/test/test_typing.py2
-rw-r--r--Lib/typing.py10
-rw-r--r--Misc/NEWS.d/next/Library/2020-07-04-21-56-46.bpo-39168.DQWsXj.rst1
3 files changed, 1 insertions, 12 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index f429e88..398add0 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -1418,8 +1418,6 @@ class GenericTests(BaseTestCase):
T = TypeVar('T')
S = TypeVar('S')
with self.assertRaises(TypeError):
- Generic[T]()
- with self.assertRaises(TypeError):
Generic[T][T]
with self.assertRaises(TypeError):
Generic[T][S]
diff --git a/Lib/typing.py b/Lib/typing.py
index f94996d..fd657ca 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -894,16 +894,6 @@ class Generic:
__slots__ = ()
_is_protocol = False
- def __new__(cls, *args, **kwds):
- if cls in (Generic, Protocol):
- raise TypeError(f"Type {cls.__name__} cannot be instantiated; "
- "it can be used only as a base class")
- if super().__new__ is object.__new__ and cls.__init__ is not object.__init__:
- obj = super().__new__(cls)
- else:
- obj = super().__new__(cls, *args, **kwds)
- return obj
-
@_tp_cache
def __class_getitem__(cls, params):
if not isinstance(params, tuple):
diff --git a/Misc/NEWS.d/next/Library/2020-07-04-21-56-46.bpo-39168.DQWsXj.rst b/Misc/NEWS.d/next/Library/2020-07-04-21-56-46.bpo-39168.DQWsXj.rst
new file mode 100644
index 0000000..667885e
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-07-04-21-56-46.bpo-39168.DQWsXj.rst
@@ -0,0 +1 @@
+Remove the ``__new__`` method of :class:`typing.Generic`.