diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2021-06-08 16:01:34 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-08 16:01:34 -0600 |
commit | 3e1c7167d86a2a928cdcb659094aa10bb5550c4c (patch) | |
tree | b3b071ff5636c7c5edd8d536b8732c6a2259a44c /Objects/typeobject.c | |
parent | ab36b9f83424a020fbd672f218612e6f19257a32 (diff) | |
download | cpython-git-3e1c7167d86a2a928cdcb659094aa10bb5550c4c.tar.gz |
bpo-43693: Un-revert commit f3fa63e. (#26609)
This was reverted in GH-26596 (commit 6d518bb) due to some bad memory accesses.
* Add the MAKE_CELL opcode. (gh-26396)
The memory accesses have been fixed.
https://bugs.python.org/issue43693
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r-- | Objects/typeobject.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index bd2cade3bd..4c7e5d4567 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -11,6 +11,8 @@ #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_unionobject.h" // _Py_Union(), _Py_union_type_or #include "frameobject.h" +#include "pycore_frame.h" // _PyFrame_OpAlreadyRan +#include "opcode.h" // MAKE_CELL #include "structmember.h" // PyMemberDef #include <ctype.h> @@ -8877,14 +8879,17 @@ super_init_without_args(PyFrameObject *f, PyCodeObject *co, } PyObject *obj = f->f_localsptr[0]; - Py_ssize_t i; + int i; if (obj == NULL && co->co_cell2arg) { /* The first argument might be a cell. */ for (i = 0; i < co->co_ncellvars; i++) { if (co->co_cell2arg[i] == 0) { - PyObject *cell = f->f_localsptr[co->co_nlocals + i]; - assert(PyCell_Check(cell)); - obj = PyCell_GET(cell); + int celloffset = co->co_nlocals + i; + PyObject *cell = f->f_localsptr[celloffset]; + if (PyCell_Check(cell) && + _PyFrame_OpAlreadyRan(f, MAKE_CELL, celloffset)) { + obj = PyCell_GET(cell); + } break; } } |