bpo-45121: Fix RecursionError when calling Protocol.__init__ from a subclass' __init__ (GH-28206) (GH-28232)

(cherry picked from commit c11956a8bd)

Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-09-08 08:05:23 -07:00 committed by GitHub
parent 2fe15dbaad
commit c081649e6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

@ -1604,6 +1604,16 @@ class P(Protocol):
with self.assertRaisesRegex(TypeError, "@runtime_checkable"):
isinstance(1, P)
def test_super_call_init(self):
class P(Protocol):
x: int
class Foo(P):
def __init__(self):
super().__init__()
Foo() # Previously triggered RecursionError
class GenericTests(BaseTestCase):