summaryrefslogtreecommitdiff
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2008-05-08 04:26:35 +0000
committerBarry Warsaw <barry@python.org>2008-05-08 04:26:35 +0000
commit651abf07a2d9af45ac35afd5cc76fa40effad1b2 (patch)
tree6f1c50c7831ac0c4ff56ec6259a7185815dadbd0 /Python/ceval.c
parentd38ecd86538a391972a025161888caed0ef7b249 (diff)
downloadcpython-651abf07a2d9af45ac35afd5cc76fa40effad1b2.tar.gz
Antoine Pitrou's patch for bug 2507; exception state lives too long in
3.0.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index bac8278126..defd00299f 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1477,6 +1477,19 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
"'finally' pops bad exception");
why = WHY_EXCEPTION;
}
+ /*
+ Make sure the exception state is cleaned up before
+ the end of an except block. This ensures objects
+ referenced by the exception state are not kept
+ alive too long.
+ See #2507.
+ */
+ if (tstate->frame->f_exc_type != NULL)
+ reset_exc_info(tstate);
+ else {
+ assert(tstate->frame->f_exc_value == NULL);
+ assert(tstate->frame->f_exc_traceback == NULL);
+ }
Py_DECREF(v);
break;