[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-07 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


--
nosy: +Jelle Zijlstra, kj

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-07 Thread Eric V. Smith


Eric V. Smith  added the comment:

Sorry I didn't notice your reference to issue 45081.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-07 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
keywords: +patch
nosy: +uriyyo
nosy_count: 3.0 -> 4.0
pull_requests: +26630
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28206

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Shantanu


Shantanu  added the comment:

Sorry if my message was confusing. Hopefully the following makes things clear:

3.9.6: snippet runs without error

3.9.7, with bpo-44806: (a probably reasonable) TypeError, but a breaking change

main, with bpo-45081: RecursionError

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Shantanu


Shantanu  added the comment:

As I mentioned in the post, bpo-45081 actually makes this issue worse, since we 
get a RecursionError.

I think `TypeError: Protocols cannot be instantiated` is probably okay 
behaviour (as opposed to RecursionError), more just unfortunate that it seems 
to be an unanticipated breaking change.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

Possibly related to issue 45081, which ended up not having anything to do with 
dataclasses (despite the title).

Can you check if that fix solves your problem?

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Shantanu


Change by Shantanu :


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Shantanu


New submission from Shantanu :

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 
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.

--
components: Library (Lib)
messages: 401184
nosy: hauntsaninja
priority: normal
severity: normal
status: open
title: Regression in 3.9.7 with typing.Protocol
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com