This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hauntsaninja
Recipients hauntsaninja
Date 2021-09-06.22:05:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1630965920.35.0.627159261173.issue45121@roundup.psfhosted.org>
In-reply-to
Content
Consider:
```
from typing import Protocol

class P(Protocol):
    ...

class C(P):
    def __init__(self):
        super().__init__()

C()
```
This code passes without error on 3.9.6.

With 3.9.7, we get:
```
Traceback (most recent call last):
  File "/Users/shantanu/dev/test.py", line 10, in <module>
    C()
  File "/Users/shantanu/dev/test.py", line 8, in __init__
    super().__init__()
  File "/Users/shantanu/.pyenv/versions/3.9.7/lib/python3.9/typing.py", line 1083, in _no_init
    raise TypeError('Protocols cannot be instantiated')
TypeError: Protocols cannot be instantiated
```

I bisected this to:

bpo-44806: Fix __init__ in subclasses of protocols (GH-27545) (GH-27559)

Note there is also an interaction with the later commit:

bpo-45081: Fix __init__ method generation when inheriting from Protocol (GH-28121) (GH-28132)

This later commit actually causes a RecursionError:
```
  File "/Users/shantanu/dev/cpython/Lib/typing.py", line 1103, in _no_init_or_replace_init
    cls.__init__(self, *args, **kwargs)
  File "/Users/shantanu/dev/test.py", line 8, in __init__
    super().__init__()
  File "/Users/shantanu/dev/cpython/Lib/typing.py", line 1103, in _no_init_or_replace_init
    cls.__init__(self, *args, **kwargs)
  File "/Users/shantanu/dev/test.py", line 8, in __init__
    super().__init__()
```

Originally reported by @tyralla on Gitter.
History
Date User Action Args
2021-09-06 22:05:20hauntsaninjasetrecipients: + hauntsaninja
2021-09-06 22:05:20hauntsaninjasetmessageid: <1630965920.35.0.627159261173.issue45121@roundup.psfhosted.org>
2021-09-06 22:05:20hauntsaninjalinkissue45121 messages
2021-09-06 22:05:20hauntsaninjacreate