Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 470cf8d

Browse files
committed
(Merge 3.4) Issue #21418: Fix a crash in the builtin function super() when
called without argument and without current frame (ex: embedded Python).
2 parents 933da8e + 1c6970f commit 470cf8d

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Release date: TBA
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #21418: Fix a crash in the builtin function super() when called without
14+
argument and without current frame (ex: embedded Python).
15+
1316
- Issue #21425: Fix flushing of standard streams in the interactive
1417
interpreter.
1518

Objects/typeobject.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6929,9 +6929,16 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
69296929
if (type == NULL) {
69306930
/* Call super(), without args -- fill in from __class__
69316931
and first local variable on the stack. */
6932-
PyFrameObject *f = PyThreadState_GET()->frame;
6933-
PyCodeObject *co = f->f_code;
6932+
PyFrameObject *f;
6933+
PyCodeObject *co;
69346934
Py_ssize_t i, n;
6935+
f = PyThreadState_GET()->frame;
6936+
if (f == NULL) {
6937+
PyErr_SetString(PyExc_RuntimeError,
6938+
"super(): no current frame");
6939+
return -1;
6940+
}
6941+
co = f->f_code;
69356942
if (co == NULL) {
69366943
PyErr_SetString(PyExc_RuntimeError,
69376944
"super(): no code object");

0 commit comments

Comments
 (0)