summaryrefslogtreecommitdiffstats
path: root/Objects/frameobject.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-03-11 08:21:13 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-03-11 08:21:13 (GMT)
commit20ac11a9fb027f183914bbaaaed091b57c882e54 (patch)
tree1ef4ea3f3f43039ec2c34d69dee395fe06e90062 /Objects/frameobject.c
parent3f439d14ad48f5d4f6017fc814326fb1f6237b53 (diff)
downloadcpython-20ac11a9fb027f183914bbaaaed091b57c882e54.zip
cpython-20ac11a9fb027f183914bbaaaed091b57c882e54.tar.gz
cpython-20ac11a9fb027f183914bbaaaed091b57c882e54.tar.bz2
[3.6] bpo-33026: Fix jumping out of "with" block by setting f_lineno. (GH-6026). (GH-6074) (GH-6075)
(cherry picked from commit 26c9f565d016db21257a60d29ab2c99383dd5ac7) (cherry picked from commit 04aadf23eac51fec2e436c5960c1362bbb7d03de) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r--Objects/frameobject.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 62f9f34..5c73e85 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -317,6 +317,13 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
PyObject *v = (*--f->f_stacktop);
Py_DECREF(v);
}
+ if (b->b_type == SETUP_FINALLY &&
+ code[b->b_handler] == WITH_CLEANUP_START)
+ {
+ /* Pop the exit function. */
+ PyObject *v = (*--f->f_stacktop);
+ Py_DECREF(v);
+ }
}
/* Finally set the new f_lineno and f_lasti and return OK. */