summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-05-09 15:52:02 (GMT)
committerGitHub <noreply@github.com>2019-05-09 15:52:02 (GMT)
commitf00828a742d2e88c910bdfd00f08fcd998554ba5 (patch)
tree3a8b1c942d314019153162b4b56860556eae3a68 /Python/ceval.c
parent33e067d6a237ced8fd2ead70a461025fd91239be (diff)
downloadcpython-f00828a742d2e88c910bdfd00f08fcd998554ba5.zip
cpython-f00828a742d2e88c910bdfd00f08fcd998554ba5.tar.gz
cpython-f00828a742d2e88c910bdfd00f08fcd998554ba5.tar.bz2
bpo-36851: Clean the frame stack if the execution ends with a return and the stack is not empty (GH-13191)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 4e43df2..07db1d3 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1755,7 +1755,7 @@ main_loop:
case TARGET(RETURN_VALUE): {
retval = POP();
assert(f->f_iblock == 0);
- goto return_or_yield;
+ goto exit_returning;
}
case TARGET(GET_AITER): {
@@ -1924,7 +1924,7 @@ main_loop:
/* and repeat... */
assert(f->f_lasti >= (int)sizeof(_Py_CODEUNIT));
f->f_lasti -= sizeof(_Py_CODEUNIT);
- goto return_or_yield;
+ goto exit_yielding;
}
case TARGET(YIELD_VALUE): {
@@ -1941,7 +1941,7 @@ main_loop:
}
f->f_stacktop = stack_pointer;
- goto return_or_yield;
+ goto exit_yielding;
}
case TARGET(POP_EXCEPT): {
@@ -3581,16 +3581,18 @@ exception_unwind:
break;
} /* main loop */
+ assert(retval == NULL);
+ assert(PyErr_Occurred());
+
+exit_returning:
+
/* Pop remaining stack entries. */
while (!EMPTY()) {
PyObject *o = POP();
Py_XDECREF(o);
}
- assert(retval == NULL);
- assert(PyErr_Occurred());
-
-return_or_yield:
+exit_yielding:
if (tstate->use_tracing) {
if (tstate->c_tracefunc) {
if (call_trace_protected(tstate->c_tracefunc, tstate->c_traceobj,