You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason seems to be that the both gerator-expressions are using the same bytecode (it should not be the same bytecode, because the code is on different lines).
Adding one newline changes the situation (which I can not explain).
Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython/ex.py", line 12, in <module>
f()
File "/Users/sobolev/Desktop/cpython/ex.py", line 5, in f
q+"" for q in [""])==list(
^^^^^
File "/Users/sobolev/Desktop/cpython/ex.py", line 7, in <genexpr>
q+"" for q in [5])
~^~~
TypeError: unsupported operand type(s) for +: 'int' and 'str'
One similar issue I know there is #95150 (which I reported) but this was only a problem if the comprehension are on the same line.
There where some bigger changes in 3.11 for the line number code. It might be that this issue was fixed without knowing that it existed. But this is only speculation.
The following code produces the wrong line number in the traceback.
script:
output (Python 3.8.12):
The traceback shows that
q
is iterating over[""]
and the exception says thatq
is anint
.the expected output in the traceback would be:
The reason seems to be that the both gerator-expressions are using the same bytecode (it should not be the same bytecode, because the code is on different lines).
Adding one newline changes the situation (which I can not explain).
script:
output (Python 3.8.12):
I bisected the bug town to this commit: b619b09
The same problem exists also for list/set/dict-expressions
The text was updated successfully, but these errors were encountered: