summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-06-15 20:09:12 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-06-15 20:09:12 (GMT)
commit27d63678a31f1adcf5f2f0f9f88d6b78e93a9c52 (patch)
tree2c0b37937bc9fc2c8507b1baf630bb97d38d2493 /Python
parentdf6dc8f10770f92db68c69d87abe7c89774d128c (diff)
downloadcpython-27d63678a31f1adcf5f2f0f9f88d6b78e93a9c52.zip
cpython-27d63678a31f1adcf5f2f0f9f88d6b78e93a9c52.tar.gz
cpython-27d63678a31f1adcf5f2f0f9f88d6b78e93a9c52.tar.bz2
improvements to the fix for #3114
keep the tstate consistent and a better test
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 4b14784..ec279bf 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -699,29 +699,39 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
}
#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() \