jpayne@69: #ifndef Py_CPYTHON_ERRORS_H jpayne@69: # error "this header file must not be included directly" jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* Error objects */ jpayne@69: jpayne@69: /* PyException_HEAD defines the initial segment of every exception class. */ jpayne@69: #define PyException_HEAD PyObject_HEAD PyObject *dict;\ jpayne@69: PyObject *args; PyObject *traceback;\ jpayne@69: PyObject *context; PyObject *cause;\ jpayne@69: char suppress_context; jpayne@69: jpayne@69: typedef struct { jpayne@69: PyException_HEAD jpayne@69: } PyBaseExceptionObject; jpayne@69: jpayne@69: typedef struct { jpayne@69: PyException_HEAD jpayne@69: PyObject *msg; jpayne@69: PyObject *filename; jpayne@69: PyObject *lineno; jpayne@69: PyObject *offset; jpayne@69: PyObject *text; jpayne@69: PyObject *print_file_and_line; jpayne@69: } PySyntaxErrorObject; jpayne@69: jpayne@69: typedef struct { jpayne@69: PyException_HEAD jpayne@69: PyObject *msg; jpayne@69: PyObject *name; jpayne@69: PyObject *path; jpayne@69: } PyImportErrorObject; jpayne@69: jpayne@69: typedef struct { jpayne@69: PyException_HEAD jpayne@69: PyObject *encoding; jpayne@69: PyObject *object; jpayne@69: Py_ssize_t start; jpayne@69: Py_ssize_t end; jpayne@69: PyObject *reason; jpayne@69: } PyUnicodeErrorObject; jpayne@69: jpayne@69: typedef struct { jpayne@69: PyException_HEAD jpayne@69: PyObject *code; jpayne@69: } PySystemExitObject; jpayne@69: jpayne@69: typedef struct { jpayne@69: PyException_HEAD jpayne@69: PyObject *myerrno; jpayne@69: PyObject *strerror; jpayne@69: PyObject *filename; jpayne@69: PyObject *filename2; jpayne@69: #ifdef MS_WINDOWS jpayne@69: PyObject *winerror; jpayne@69: #endif jpayne@69: Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */ jpayne@69: } PyOSErrorObject; jpayne@69: jpayne@69: typedef struct { jpayne@69: PyException_HEAD jpayne@69: PyObject *value; jpayne@69: } PyStopIterationObject; jpayne@69: jpayne@69: /* Compatibility typedefs */ jpayne@69: typedef PyOSErrorObject PyEnvironmentErrorObject; jpayne@69: #ifdef MS_WINDOWS jpayne@69: typedef PyOSErrorObject PyWindowsErrorObject; jpayne@69: #endif jpayne@69: jpayne@69: /* Error handling definitions */ jpayne@69: jpayne@69: PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *); jpayne@69: _PyErr_StackItem *_PyErr_GetTopmostException(PyThreadState *tstate); jpayne@69: jpayne@69: /* Context manipulation (PEP 3134) */ jpayne@69: jpayne@69: PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *); jpayne@69: jpayne@69: /* */ jpayne@69: jpayne@69: #define PyExceptionClass_Name(x) (((PyTypeObject*)(x))->tp_name) jpayne@69: jpayne@69: /* Convenience functions */ jpayne@69: jpayne@69: #ifdef MS_WINDOWS jpayne@69: Py_DEPRECATED(3.3) jpayne@69: PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename( jpayne@69: PyObject *, const Py_UNICODE *); jpayne@69: #endif /* MS_WINDOWS */ jpayne@69: jpayne@69: /* Like PyErr_Format(), but saves current exception as __context__ and jpayne@69: __cause__. jpayne@69: */ jpayne@69: PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause( jpayne@69: PyObject *exception, jpayne@69: const char *format, /* ASCII-encoded string */ jpayne@69: ... jpayne@69: ); jpayne@69: jpayne@69: #ifdef MS_WINDOWS jpayne@69: /* XXX redeclare to use WSTRING */ jpayne@69: Py_DEPRECATED(3.3) jpayne@69: PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename( jpayne@69: int, const Py_UNICODE *); jpayne@69: Py_DEPRECATED(3.3) jpayne@69: PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( jpayne@69: PyObject *,int, const Py_UNICODE *); jpayne@69: #endif jpayne@69: jpayne@69: /* In exceptions.c */ jpayne@69: jpayne@69: /* Helper that attempts to replace the current exception with one of the jpayne@69: * same type but with a prefix added to the exception text. The resulting jpayne@69: * exception description looks like: jpayne@69: * jpayne@69: * prefix (exc_type: original_exc_str) jpayne@69: * jpayne@69: * Only some exceptions can be safely replaced. If the function determines jpayne@69: * it isn't safe to perform the replacement, it will leave the original jpayne@69: * unmodified exception in place. jpayne@69: * jpayne@69: * Returns a borrowed reference to the new exception (if any), NULL if the jpayne@69: * existing exception was left in place. jpayne@69: */ jpayne@69: PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause( jpayne@69: const char *prefix_format, /* ASCII-encoded string */ jpayne@69: ... jpayne@69: ); jpayne@69: jpayne@69: /* In signalmodule.c */ jpayne@69: jpayne@69: int PySignal_SetWakeupFd(int fd); jpayne@69: PyAPI_FUNC(int) _PyErr_CheckSignals(void); jpayne@69: jpayne@69: /* Support for adding program text to SyntaxErrors */ jpayne@69: jpayne@69: PyAPI_FUNC(void) PyErr_SyntaxLocationObject( jpayne@69: PyObject *filename, jpayne@69: int lineno, jpayne@69: int col_offset); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject( jpayne@69: PyObject *filename, jpayne@69: int lineno); jpayne@69: jpayne@69: /* Create a UnicodeEncodeError object */ jpayne@69: Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create( jpayne@69: const char *encoding, /* UTF-8 encoded string */ jpayne@69: const Py_UNICODE *object, jpayne@69: Py_ssize_t length, jpayne@69: Py_ssize_t start, jpayne@69: Py_ssize_t end, jpayne@69: const char *reason /* UTF-8 encoded string */ jpayne@69: ); jpayne@69: jpayne@69: /* Create a UnicodeTranslateError object */ jpayne@69: Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( jpayne@69: const Py_UNICODE *object, jpayne@69: Py_ssize_t length, jpayne@69: Py_ssize_t start, jpayne@69: Py_ssize_t end, jpayne@69: const char *reason /* UTF-8 encoded string */ jpayne@69: ); jpayne@69: PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create( jpayne@69: PyObject *object, jpayne@69: Py_ssize_t start, jpayne@69: Py_ssize_t end, jpayne@69: const char *reason /* UTF-8 encoded string */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(void) _PyErr_WriteUnraisableMsg( jpayne@69: const char *err_msg, jpayne@69: PyObject *obj); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif