diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-05-12 23:16:06 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-05-12 23:16:06 (GMT) |
commit | 159ae41da68ff1f1d85ed66fa6410bd9ba62ed5b (patch) | |
tree | 379d3664706b0a0dcc7d32f762d88595ae8e84bf /Objects | |
parent | 3bfc5f5d833f081089e181cadf52d4ec50e62d13 (diff) | |
download | cpython-159ae41da68ff1f1d85ed66fa6410bd9ba62ed5b.zip cpython-159ae41da68ff1f1d85ed66fa6410bd9ba62ed5b.tar.gz cpython-159ae41da68ff1f1d85ed66fa6410bd9ba62ed5b.tar.bz2 |
when an argument is a cell, set the local copy to NULL (see #17927)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index e418a3a..a351667 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6510,9 +6510,17 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds) return -1; } obj = f->f_localsplus[0]; - if (obj != NULL && PyCell_Check(obj)) { - /* It might be a cell. See cell var initialization in ceval.c. */ - obj = PyCell_GET(obj); + 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, |