mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #21418: Fix a crash in the builtin function super() when called without
argument and without current frame (ex: embedded Python).
This commit is contained in:
parent
b0539b27d9
commit
1c6970fac9
2 changed files with 12 additions and 2 deletions
|
@ -6919,9 +6919,16 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
if (type == NULL) {
|
||||
/* Call super(), without args -- fill in from __class__
|
||||
and first local variable on the stack. */
|
||||
PyFrameObject *f = PyThreadState_GET()->frame;
|
||||
PyCodeObject *co = f->f_code;
|
||||
PyFrameObject *f;
|
||||
PyCodeObject *co;
|
||||
Py_ssize_t i, n;
|
||||
f = PyThreadState_GET()->frame;
|
||||
if (f == NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"super(): no current frame");
|
||||
return -1;
|
||||
}
|
||||
co = f->f_code;
|
||||
if (co == NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"super(): no code object");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue