when an argument is a cell, set the local copy to NULL (see #17927)

This commit is contained in:
Benjamin Peterson 2013-05-12 18:16:06 -05:00
parent 3bfc5f5d83
commit 159ae41da6
3 changed files with 28 additions and 11 deletions

View file

@ -3521,18 +3521,14 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
if (co->co_cell2arg != NULL &&
(arg = co->co_cell2arg[i]) != CO_CELL_NOT_AN_ARG) {
c = PyCell_New(GETLOCAL(arg));
if (c == NULL)
goto fail;
/* Reference the cell from the argument slot, for super().
See typeobject.c. */
Py_INCREF(c);
SETLOCAL(arg, c);
/* Clear the local copy. */
SETLOCAL(arg, NULL);
}
else {
c = PyCell_New(NULL);
if (c == NULL)
goto fail;
}
if (c == NULL)
goto fail;
SETLOCAL(co->co_nlocals + i, c);
}
for (i = 0; i < PyTuple_GET_SIZE(co->co_freevars); ++i) {