Commit 1c6970fa authored by Victor Stinner's avatar Victor Stinner

Issue #21418: Fix a crash in the builtin function super() when called without

argument and without current frame (ex: embedded Python).
parent b0539b27
...@@ -10,6 +10,9 @@ Release date: TBA ...@@ -10,6 +10,9 @@ Release date: TBA
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #21418: Fix a crash in the builtin function super() when called without
argument and without current frame (ex: embedded Python).
- Issue #21425: Fix flushing of standard streams in the interactive - Issue #21425: Fix flushing of standard streams in the interactive
interpreter. interpreter.
......
...@@ -6919,9 +6919,16 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -6919,9 +6919,16 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
if (type == NULL) { if (type == NULL) {
/* Call super(), without args -- fill in from __class__ /* Call super(), without args -- fill in from __class__
and first local variable on the stack. */ and first local variable on the stack. */
PyFrameObject *f = PyThreadState_GET()->frame; PyFrameObject *f;
PyCodeObject *co = f->f_code; PyCodeObject *co;
Py_ssize_t i, n; 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) { if (co == NULL) {
PyErr_SetString(PyExc_RuntimeError, PyErr_SetString(PyExc_RuntimeError,
"super(): no code object"); "super(): no code object");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment