I am observing the following weird behavior in IntelliJ 2020.03 with Python 3.9 on a Mac (but this also occurrs on another IntelliJ Version on an Ubuntu system).
If we consider the following minimal example:
def foo(bar):
pass
foo(False)
Now I set a conditional breakpoint in IntelliJ in line 2 that conditions on:
[bar for _ in range(1)]
When I now run the script in debug mode, I get an error:
Error while evaluating expression: [bar for _ in range(1)]
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 1, in <listcomp>
NameError: name 'bar' is not defined
So my question is simple: Why is bar not defined in the generator? (The crucial point to reproduce is to reference bar in some generator, otherwise it is defined (of course?)
Regrettably, it has been confirmed as a bug https://youtrack.jetbrains.com/issue/PY-47695.
I apologize for the inconvenience.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With