mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
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:
parent
2fe15dbaad
commit
c081649e6d
3 changed files with 17 additions and 0 deletions
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue