summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-05-12 23:32:36 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-05-12 23:32:36 (GMT)
commit1c6970fac994be2b1f9e3415e09c07ff01657563 (patch)
tree3f9cf62986cec2c97af62133482babb903e3c57f /Objects
parentb0539b27d9a195b78a5713cc3d4aa98ea07dbc53 (diff)
downloadcpython-1c6970fac994be2b1f9e3415e09c07ff01657563.zip
cpython-1c6970fac994be2b1f9e3415e09c07ff01657563.tar.gz
cpython-1c6970fac994be2b1f9e3415e09c07ff01657563.tar.bz2
Issue #21418: Fix a crash in the builtin function super() when called without
argument and without current frame (ex: embedded Python).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 7f59d5d..ba106a139 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -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");