when arguments are cells clear the locals slot (backport of #17927)

This commit is contained in:
Benjamin Peterson 2013-05-14 22:31:26 -05:00
parent d486707d2e
commit e1b4cbc422
5 changed files with 63 additions and 2 deletions

View file

@ -6519,6 +6519,18 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
return -1;
}
obj = f->f_localsplus[0];
if (obj == NULL && co->co_cell2arg) {
/* The first argument might be a cell. */
n = PyTuple_GET_SIZE(co->co_cellvars);
for (i = 0; i < n; i++) {
if (co->co_cell2arg[i] == 0) {
PyObject *cell = f->f_localsplus[co->co_nlocals + i];
assert(PyCell_Check(cell));
obj = PyCell_GET(cell);
break;
}
}
}
if (obj == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"super(): arg[0] deleted");