bpo-39168: Remove the __new__ method of typing.Generic (GH-21327) · python/cpython@5a13849 · GitHub
Skip to content

Commit 5a13849

Browse files
bpo-39168: Remove the __new__ method of typing.Generic (GH-21327)
Automerge-Triggered-By: @gvanrossum (cherry picked from commit 7fed755) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
1 parent 16f4517 commit 5a13849

3 files changed

Lines changed: 1 addition & 12 deletions

File tree

Lib/test/test_typing.py

Lines changed: 0 additions & 2 deletions

Lib/typing.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -894,16 +894,6 @@ def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
894894
__slots__ = ()
895895
_is_protocol = False
896896

897-
def __new__(cls, *args, **kwds):
898-
if cls in (Generic, Protocol):
899-
raise TypeError(f"Type {cls.__name__} cannot be instantiated; "
900-
"it can be used only as a base class")
901-
if super().__new__ is object.__new__ and cls.__init__ is not object.__init__:
902-
obj = super().__new__(cls)
903-
else:
904-
obj = super().__new__(cls, *args, **kwds)
905-
return obj
906-
907897
@_tp_cache
908898
def __class_getitem__(cls, params):
909899
if not isinstance(params, tuple):
Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)