Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 47729:ee2823e1f23b
improvements to the fix for #3114
keep the tstate consistent and a better test
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sun, 15 Jun 2008 20:09:12 +0000 |
| parents | b33e8334f82f |
| children | aca5b2e6a66f |
line wrap: on
line diff
--- a/Python/ceval.c Sun Jun 15 02:57:40 2008 +0000 +++ b/Python/ceval.c Sun Jun 15 20:09:12 2008 +0000 @@ -699,29 +699,39 @@ } #define UNWIND_EXCEPT_HANDLER(b) \ - assert(STACK_LEVEL() >= (b)->b_level + 3); \ - while (STACK_LEVEL() > (b)->b_level + 3) { \ - PyObject *v = POP(); \ - Py_XDECREF(v); \ - } \ - Py_CLEAR(tstate->exc_type); \ - Py_CLEAR(tstate->exc_value); \ - Py_CLEAR(tstate->exc_traceback); \ - tstate->exc_type = POP(); \ - tstate->exc_value = POP(); \ - tstate->exc_traceback = POP(); + { \ + PyObject *type, *value, *traceback; \ + assert(STACK_LEVEL() >= (b)->b_level + 3); \ + while (STACK_LEVEL() > (b)->b_level + 3) { \ + value = POP(); \ + Py_XDECREF(value); \ + } \ + type = tstate->exc_type; \ + value = tstate->exc_value; \ + traceback = tstate->exc_traceback; \ + tstate->exc_type = POP(); \ + tstate->exc_value = POP(); \ + tstate->exc_traceback = POP(); \ + Py_XDECREF(type); \ + Py_XDECREF(value); \ + Py_XDECREF(traceback); \ + } #define SAVE_EXC_STATE() \ { \ + PyObject *type, *value, *traceback; \ Py_XINCREF(tstate->exc_type); \ Py_XINCREF(tstate->exc_value); \ Py_XINCREF(tstate->exc_traceback); \ - Py_CLEAR(f->f_exc_type); \ - Py_CLEAR(f->f_exc_value); \ - Py_CLEAR(f->f_exc_traceback); \ + type = f->f_exc_type; \ + value = f->f_exc_value; \ + traceback = f->f_exc_traceback; \ f->f_exc_type = tstate->exc_type; \ f->f_exc_value = tstate->exc_value; \ f->f_exc_traceback = tstate->exc_traceback; \ + Py_XDECREF(type); \ + Py_XDECREF(value); \ + Py_XDECREF(traceback); \ } #define SWAP_EXC_STATE() \
