diff options
author | Collin Winter <collinw@gmail.com> | 2007-08-31 00:04:24 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-08-31 00:04:24 (GMT) |
commit | 828f04ac3f0dd3b68b4dbf42a79ebb846d1de568 (patch) | |
tree | 21e25d3d969ce636c32539e4d4b5255dc4c85702 /Include | |
parent | 150b7d7d02eca6970d792f3e6887f957a36b6ca2 (diff) | |
download | cpython-828f04ac3f0dd3b68b4dbf42a79ebb846d1de568.zip cpython-828f04ac3f0dd3b68b4dbf42a79ebb846d1de568.tar.gz cpython-828f04ac3f0dd3b68b4dbf42a79ebb846d1de568.tar.bz2 |
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/Python-ast.h | 11 | ||||
-rw-r--r-- | Include/pyerrors.h | 46 |
2 files changed, 31 insertions, 26 deletions
diff --git a/Include/Python-ast.h b/Include/Python-ast.h index 174a841..51e5298 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -134,9 +134,8 @@ struct _stmt { } With; struct { - expr_ty type; - expr_ty inst; - expr_ty tback; + expr_ty exc; + expr_ty cause; } Raise; struct { @@ -418,9 +417,9 @@ stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, #define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5) stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int lineno, int col_offset, PyArena *arena); -#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int - col_offset, PyArena *arena); +#define Raise(a0, a1, a2, a3, a4) _Py_Raise(a0, a1, a2, a3, a4) +stmt_ty _Py_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, + PyArena *arena); #define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5) stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int lineno, int col_offset, PyArena *arena); diff --git a/Include/pyerrors.h b/Include/pyerrors.h index ca187e4..8d676d9 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -6,16 +6,17 @@ extern "C" { /* Error objects */ +/* PyException_HEAD defines the initial segment of every exception class. */ +#define PyException_HEAD PyObject_HEAD; PyObject *dict;\ + PyObject *args; PyObject *traceback;\ + PyObject *context; PyObject *cause; + typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; + PyException_HEAD } PyBaseExceptionObject; typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; + PyException_HEAD PyObject *msg; PyObject *filename; PyObject *lineno; @@ -25,9 +26,7 @@ typedef struct { } PySyntaxErrorObject; typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; + PyException_HEAD PyObject *encoding; PyObject *object; Py_ssize_t start; @@ -36,16 +35,12 @@ typedef struct { } PyUnicodeErrorObject; typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; + PyException_HEAD PyObject *code; } PySystemExitObject; typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; + PyException_HEAD PyObject *myerrno; PyObject *strerror; PyObject *filename; @@ -53,9 +48,7 @@ typedef struct { #ifdef MS_WINDOWS typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; + PyException_HEAD PyObject *myerrno; PyObject *strerror; PyObject *filename; @@ -84,6 +77,19 @@ PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *); PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *); PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); +/* Traceback manipulation (PEP 3134) */ +PyAPI_FUNC(int) PyException_SetTraceback(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyException_GetTraceback(PyObject *); + +/* Cause manipulation (PEP 3134) */ +PyAPI_FUNC(PyObject *) PyException_GetCause(PyObject *); +PyAPI_FUNC(void) PyException_SetCause(PyObject *, PyObject *); + +/* Context manipulation (PEP 3134) */ +PyAPI_FUNC(PyObject *) PyException_GetContext(PyObject *); +PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *); + + /* */ #define PyExceptionClass_Check(x) \ @@ -98,7 +104,7 @@ PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); #define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type)) - + /* Predefined exceptions */ PyAPI_DATA(PyObject *) PyExc_BaseException; @@ -212,7 +218,7 @@ PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); PyAPI_FUNC(int) PyErr_WarnEx(PyObject *category, const char *msg, Py_ssize_t stack_level); PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, - const char *, int, + const char *, int, const char *, PyObject *); /* In sigcheck.c or signalmodule.c */ |