mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Antoine Pitrou's patch for bug 2507; exception state lives too long in
3.0.
This commit is contained in:
parent
96de30ae1e
commit
8d109cb043
2 changed files with 42 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue