bpo-46564: do not create frame object for super object by kumaraditya303 · Pull Request #31002 · python/cpython
static int super_init_without_args(PyFrameObject *f, PyCodeObject *co, super_init_without_args(InterpreterFrame *cframe, PyCodeObject *co, PyTypeObject **type_p, PyObject **obj_p) { if (co->co_argcount == 0) {
assert(f->f_frame->f_code->co_nlocalsplus > 0); PyObject *firstarg = _PyFrame_GetLocalsArray(f->f_frame)[0]; assert(cframe->f_code->co_nlocalsplus > 0); PyObject *firstarg = _PyFrame_GetLocalsArray(cframe)[0]; // The first argument might be a cell. if (firstarg != NULL && (_PyLocals_GetKind(co->co_localspluskinds, 0) & CO_FAST_CELL)) { // "firstarg" is a cell here unless (very unlikely) super() // was called from the C-API before the first MAKE_CELL op. if (f->f_frame->f_lasti >= 0) { if (cframe->f_lasti >= 0) { assert(_Py_OPCODE(*co->co_firstinstr) == MAKE_CELL || _Py_OPCODE(*co->co_firstinstr) == COPY_FREE_VARS); assert(PyCell_Check(firstarg)); firstarg = PyCell_GET(firstarg);
PyCodeObject *code = PyFrame_GetCode(frame); int res = super_init_without_args(frame, code, &type, &obj); Py_DECREF(frame); Py_DECREF(code); int res = super_init_without_args(cframe, cframe->f_code, &type, &obj);
if (res < 0) { return -1;