diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-05-12 23:32:54 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-05-12 23:32:54 (GMT) |
commit | 470cf8dfbedbaa38a9076083a4f697f2b17c0c53 (patch) | |
tree | 83d02c88f1c1575099b7e485859542bcb760a110 /Objects | |
parent | 933da8efb7987f0bb7fac733d82d48eb65bc84a2 (diff) | |
parent | 1c6970fac994be2b1f9e3415e09c07ff01657563 (diff) | |
download | cpython-470cf8dfbedbaa38a9076083a4f697f2b17c0c53.zip cpython-470cf8dfbedbaa38a9076083a4f697f2b17c0c53.tar.gz cpython-470cf8dfbedbaa38a9076083a4f697f2b17c0c53.tar.bz2 |
(Merge 3.4) 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.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index be9747a..c759204 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6929,9 +6929,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"); |