diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-05-14 22:31:26 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-05-14 22:31:26 -0500 |
commit | e1b4cbc422efc2cc6c5bbbf26645dbb5c001cb49 (patch) | |
tree | 532371b6a46fa021141c9be584dcfab109c3114f /Objects/typeobject.c | |
parent | d486707d2e36f3141da3a3845066e7dabfd94198 (diff) | |
download | cpython3-e1b4cbc422efc2cc6c5bbbf26645dbb5c001cb49.tar.gz |
when arguments are cells clear the locals slot (backport of #17927)
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r-- | Objects/typeobject.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f40dd10a34..a55d9775de 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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"); |