diff options
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r-- | Objects/frameobject.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 035c2c5..01fb565 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -909,9 +909,12 @@ PyFrame_LocalsToFast(PyFrameObject *f, int clear) if (ncells || nfreevars) { dict_to_map(co->co_cellvars, ncells, locals, fast + co->co_nlocals, 1, clear); - dict_to_map(co->co_freevars, nfreevars, - locals, fast + co->co_nlocals + ncells, 1, - clear); + /* Same test as in PyFrame_FastToLocals() above. */ + if (co->co_flags & CO_OPTIMIZED) { + dict_to_map(co->co_freevars, nfreevars, + locals, fast + co->co_nlocals + ncells, 1, + clear); + } } PyErr_Restore(error_type, error_value, error_traceback); } |