-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent debugger behavior #16790
Comments
Hi @OverLordGoldDragon thanks for the feedback! I was able to reproduce this (not totally sure though why it could be happening). Also, while testing, if I just run the code from a file using the Maybe this related with the handling of variables inside a Maybe @ccordoba12 or @impact27 have some ideas to check what could be happening? |
With our mitigations for https://bugs.python.org/issue41918: In [1]: import numpy as np
...: a = np.arange(3)
...: b = np.arange(3) * 10
In [2]: %debug print
NOTE: Enter 'c' at the ipdb> prompt to continue execution.
> <string>(1)<module>()
IPdb [1]: for c0 in a: print([(c0, c1) for c1 in b])
*** NameError: name 'c0' is not defined
IPdb [2]: for c0 in a: print([(c0, c1) for c1 in b])
[(0, 0), (0, 10), (0, 20)]
[(0, 0), (0, 10), (0, 20)]
[(0, 0), (0, 10), (0, 20)]
IPdb [3]: Without: In [2]: import numpy as np
...: a = np.arange(3)
...: b = np.arange(3) * 10
In [3]: %debug print
NOTE: Enter 'c' at the ipdb> prompt to continue execution.
> <string>(1)<module>()
IPdb [1]: for c0 in a: print([(c0, c1) for c1 in b])
[(0, 0), (0, 10), (0, 20)]
[(1, 0), (1, 10), (1, 20)]
[(2, 0), (2, 10), (2, 20)]
IPdb [2]: |
Seeing this: In [2]: import numpy as np
In [3]: exec("for c0 in a: print([(c0, c1) for c1 in b])", {"a": np.arange(3), "b": np.arange(3) * 10})
[(0, 0), (0, 10), (0, 20)]
[(1, 0), (1, 10), (1, 20)]
[(2, 0), (2, 10), (2, 20)]
In [4]: exec("for c0 in a: print([(c0, c1) for c1 in b])", {"a": np.arange(3), "b": np.arange(3) * 10}, {})
Traceback (most recent call last):
File "/var/folders/xx/mbs7xxcs2397g51c4kbg23p00000gp/T/ipykernel_33146/640046553.py", line 1, in <module>
exec("for c0 in a: print([(c0, c1) for c1 in b])", {"a": np.arange(3), "b": np.arange(3) * 10}, {})
File "<string>", line 1, in <module>
File "<string>", line 1, in <listcomp>
NameError: name 'c0' is not defined
In [5]: I think we should not give locals when running code that has comprehensions. |
Inside debugger
but outside, it's a consistent
Data here. Code
Windows 10, Python 3.8.12, minimal install
conda create -y -n spy5 spyder==5.1.5 -c conda-forge
plusconda install -c conda-forge numpy
conda list
The text was updated successfully, but these errors were encountered: