-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The following fails in Python 3.12 (but not 3.11 or 3.13):
# Setup: in global scope, use a comprehension with colliding variable name
foo = None
[foo for foo in [0]]
# Repro: assigning to frame.f_locals and then merging to fast works only the first time
import inspect, ctypes
frame = inspect.currentframe()
frame.f_locals['a'] = 1
ctypes.pythonapi.PyFrame_LocalsToFast(ctypes.py_object(frame), ctypes.c_int(0))
print(a) # 1
frame.f_locals['b'] = 2
ctypes.pythonapi.PyFrame_LocalsToFast(ctypes.py_object(frame), ctypes.c_int(0))
print(b) # NameError: name 'b' is not defined
This impacts debuggers' ability to assign and evaluate local variables -- see microsoft/debugpy#1849 and microsoft/debugpy#1636.
Possibly related changes:
- gh-105340: include hidden fast-locals in locals() #105715
- gh-108732: include comprehension locals in frame.f_locals #109026
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error