-
-
Notifications
You must be signed in to change notification settings - Fork 32k
frame.f_locals
for list/dict/set comprehension in module/class scope doesn't contain iteration variables
#108732
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
Comments
Thanks for the report! Attached PR fixes this. Sorry I wasn't able to get the PR up and merged in time for 3.12.0.rc2; was traveling over the long (US) holiday weekend. I think this probably means the fix will need to wait until 3.12.1, unless @Yhg1s wants to merge it between rc2 and final .0. I think the fix is low-risk, but the bug is also an edge case that is unlikely to affect a lot of users, so I think either way is probably OK. |
Co-authored-by: Radislav Chugunov <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
…onGH-109026) (cherry picked from commit f2584ea) Co-authored-by: Carl Meyer <[email protected]> Co-authored-by: Radislav Chugunov <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
…109026) (#109097) gh-108732: include comprehension locals in frame.f_locals (GH-109026) (cherry picked from commit f2584ea) Co-authored-by: Carl Meyer <[email protected]> Co-authored-by: Radislav Chugunov <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
Just stumbled upon this and I have noticed something similar with frame stacks. Not sure whether this is considered expected in 3.12
Essentially, frame stacks in 3.12 seem to be missing list (and probably other, not tested) comprehensions. |
@P403n1x87 Yes, that's expected and called out in PEP 709 as an expected impact. There are not language guarantees about what frames show up in Python frame stacks. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Checklist
and am confident this bug has not been reported before
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.13.0a0 (heads/main:dd32611f4f, Aug 31 2023, 20:23:23) [GCC 10.2.1 20210110]
A clear and concise description of the bug:
The following assertion fails with PEP 709 (c3b595e):
This was discovered when trying to inspect listcomp iteration variable under
pdb
, as it makes inspection of these variables impossible:As I can see, it happens because iteration vars are now stored in "fast hidden locals" that aren't included into
frame->f_locals
on_PyFrame_FastToLocalsWithError(frame)
call, and thus are not accessible throughPyFrameObject
f_locals
attribute.cc @carljm
Linked PRs
The text was updated successfully, but these errors were encountered: