Environment data
- debugpy version: 1.8.12
- OS and version: Windows 11
- Python version (& distribution if applicable, e.g. Anaconda): 3.12.8
- Using VS Code or Visual Studio: VS Code
Actual behavior
Run and debug the following, with a breakpoint on the last line:
# Global variable
foo = None
# Comprehension with colliding local variable
[foo for foo in [0]]
# Breakpoint here
debugger()
While paused, evaluate the following in debug console:
builtins.globals()["abc"] = 123
builtins.globals()["abc"]
Notice the last evaluation fails with a KeyError, even though it should have been set.
This issue only reproduces under the following circumstances:
- Python 3.12 (any patch version -- but 3.11 and 3.13 both work)
- The code is in global scope
- The iteration variable in the comprehension collides with the global variable
Expected behavior
The assignment to builtins.globals() should persist between evaluations