Issue2378: pdb would delete free variables when stepping into a class statement.
The problem was introduced by r53954, the correction is to restore the symmetry between
PyFrame_FastToLocals and PyFrame_LocalsToFast
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index d89d72d..079c831 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -904,9 +904,12 @@
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);
}