diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-06-11 15:59:43 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-06-11 15:59:43 (GMT) |
commit | eec3d7137929611b98dd593cd2f122cd91b723b2 (patch) | |
tree | 42721419d4fe3f53961ecfd7c1dea3224188ae40 /Include | |
parent | e8465f2b413174084fcc2dc4cd7a53122c62ce4b (diff) | |
download | cpython-eec3d7137929611b98dd593cd2f122cd91b723b2.zip cpython-eec3d7137929611b98dd593cd2f122cd91b723b2.tar.gz cpython-eec3d7137929611b98dd593cd2f122cd91b723b2.tar.bz2 |
#3021: Antoine Pitrou's Lexical exception handlers
Diffstat (limited to 'Include')
-rw-r--r-- | Include/frameobject.h | 14 | ||||
-rw-r--r-- | Include/opcode.h | 8 |
2 files changed, 15 insertions, 7 deletions
diff --git a/Include/frameobject.h b/Include/frameobject.h index d2afe8b..65ebd2a 100644 --- a/Include/frameobject.h +++ b/Include/frameobject.h @@ -27,13 +27,13 @@ typedef struct _frame { PyObject **f_stacktop; PyObject *f_trace; /* Trace function */ - /* If an exception is raised in this frame, the next three are used to - * record the exception info (if any) originally in the thread state. See - * comments before set_exc_info() -- it's not obvious. - * Invariant: if _type is NULL, then so are _value and _traceback. - * Desired invariant: all three are NULL, or all three are non-NULL. That - * one isn't currently true, but "should be". - */ + /* In a generator, we need to be able to swap between the exception + state inside the generator and the exception state of the calling + frame (which shouldn't be impacted when the generator "yields" + from an except handler). + These three fields exist exactly for that, and are unused for + non-generator frames. See the SAVE_EXC_STATE and SWAP_EXC_STATE + macros in ceval.c for details of their use. */ PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; PyThreadState *f_tstate; diff --git a/Include/opcode.h b/Include/opcode.h index 7bdf1c9..6da9877 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -70,6 +70,7 @@ extern "C" { #define YIELD_VALUE 86 #define POP_BLOCK 87 #define END_FINALLY 88 +#define POP_EXCEPT 89 #define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ @@ -133,6 +134,13 @@ extern "C" { #define EXTENDED_ARG 143 +/* EXCEPT_HANDLER is a special, implicit block type which is created when + entering an except handler. It is not an opcode but we define it here + as we want it to be available to both frameobject.c and ceval.c, while + remaining private.*/ +#define EXCEPT_HANDLER 257 + + enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; |