From: Benjamin Peterson Date: Sun, 28 Jun 2009 15:40:50 +0000 (+0000) Subject: correctly rearrange the stack in the exception case of WITH_CLEANUP X-Git-Tag: v3.2a1~2978 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=176101d660cdb619c74476a71eb3bbf2c32a45ca;p=python correctly rearrange the stack in the exception case of WITH_CLEANUP --- diff --git a/Python/ceval.c b/Python/ceval.c index b689f3de28..24e41689ad 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2533,10 +2533,21 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) u = v = w = Py_None; } else { + PyObject *tp, *exc, *tb; + PyTryBlock *block; v = SECOND(); w = THIRD(); + tp = FOURTH(); + exc = stack_pointer[-5]; + tb = stack_pointer[-6]; exit_func = stack_pointer[-7]; - stack_pointer[-7] = NULL; + stack_pointer[-7] = tb; + stack_pointer[-6] = exc; + stack_pointer[-5] = tp; + FOURTH() = NULL; + block = &f->f_blockstack[f->f_iblock - 1]; + assert(block->b_type == EXCEPT_HANDLER); + block->b_level--; } /* XXX Not the fastest way to call it... */ x = PyObject_CallFunctionObjArgs(exit_func, u, v, w,