mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
[3.12] gh-108732: include comprehension locals in frame.f_locals (GH-109026) (#109097)
gh-108732: include comprehension locals in frame.f_locals (GH-109026)
(cherry picked from commit f2584eade3
)
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
af83d1e821
commit
d533ab17ec
3 changed files with 19 additions and 4 deletions
|
@ -24,10 +24,16 @@ static PyMemberDef frame_memberlist[] = {
|
|||
static PyObject *
|
||||
frame_getlocals(PyFrameObject *f, void *closure)
|
||||
{
|
||||
if (PyFrame_FastToLocalsWithError(f) < 0)
|
||||
if (f == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
PyObject *locals = f->f_frame->f_locals;
|
||||
return Py_NewRef(locals);
|
||||
}
|
||||
assert(!_PyFrame_IsIncomplete(f->f_frame));
|
||||
PyObject *locals = _PyFrame_GetLocals(f->f_frame, 1);
|
||||
if (locals) {
|
||||
f->f_fast_as_locals = 1;
|
||||
}
|
||||
return locals;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1351,11 +1357,11 @@ PyFrame_GetVarString(PyFrameObject *frame, const char *name)
|
|||
int
|
||||
PyFrame_FastToLocalsWithError(PyFrameObject *f)
|
||||
{
|
||||
assert(!_PyFrame_IsIncomplete(f->f_frame));
|
||||
if (f == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
assert(!_PyFrame_IsIncomplete(f->f_frame));
|
||||
int err = _PyFrame_FastToLocalsWithError(f->f_frame);
|
||||
if (err == 0) {
|
||||
f->f_fast_as_locals = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue