1 #ifndef Py_CPYTHON_ERRORS_H 2 # error "this header file must not be included directly" 3 #endif 4 5 /* Error objects */ 6 7 /* PyException_HEAD defines the initial segment of every exception class. */ 8 #define PyException_HEAD PyObject_HEAD PyObject *dict;\ 9 PyObject *args; PyObject *notes; PyObject *traceback;\ 10 PyObject *context; PyObject *cause;\ 11 char suppress_context; 12 13 typedef struct { 14 PyException_HEAD 15 } PyBaseExceptionObject; 16 17 typedef struct { 18 PyException_HEAD 19 PyObject *msg; 20 PyObject *excs; 21 } PyBaseExceptionGroupObject; 22 23 typedef struct { 24 PyException_HEAD 25 PyObject *msg; 26 PyObject *filename; 27 PyObject *lineno; 28 PyObject *offset; 29 PyObject *end_lineno; 30 PyObject *end_offset; 31 PyObject *text; 32 PyObject *print_file_and_line; 33 } PySyntaxErrorObject; 34 35 typedef struct { 36 PyException_HEAD 37 PyObject *msg; 38 PyObject *name; 39 PyObject *path; 40 PyObject *name_from; 41 } PyImportErrorObject; 42 43 typedef struct { 44 PyException_HEAD 45 PyObject *encoding; 46 PyObject *object; 47 Py_ssize_t start; 48 Py_ssize_t end; 49 PyObject *reason; 50 } PyUnicodeErrorObject; 51 52 typedef struct { 53 PyException_HEAD 54 PyObject *code; 55 } PySystemExitObject; 56 57 typedef struct { 58 PyException_HEAD 59 PyObject *myerrno; 60 PyObject *strerror; 61 PyObject *filename; 62 PyObject *filename2; 63 #ifdef MS_WINDOWS 64 PyObject *winerror; 65 #endif 66 Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */ 67 } PyOSErrorObject; 68 69 typedef struct { 70 PyException_HEAD 71 PyObject *value; 72 } PyStopIterationObject; 73 74 typedef struct { 75 PyException_HEAD 76 PyObject *name; 77 } PyNameErrorObject; 78 79 typedef struct { 80 PyException_HEAD 81 PyObject *obj; 82 PyObject *name; 83 } PyAttributeErrorObject; 84 85 /* Compatibility typedefs */ 86 typedef PyOSErrorObject PyEnvironmentErrorObject; 87 #ifdef MS_WINDOWS 88 typedef PyOSErrorObject PyWindowsErrorObject; 89 #endif 90 91 /* Context manipulation (PEP 3134) */ 92 93 PyAPI_FUNC(void) _PyErr_ChainExceptions1(PyObject *); 94 95 /* In exceptions.c */ 96 97 PyAPI_FUNC(PyObject*) PyUnstable_Exc_PrepReraiseStar( 98 PyObject *orig, 99 PyObject *excs); 100 101 /* In signalmodule.c */ 102 103 PyAPI_FUNC(int) PySignal_SetWakeupFd(int fd); 104 105 /* Support for adding program text to SyntaxErrors */ 106 107 PyAPI_FUNC(void) PyErr_SyntaxLocationObject( 108 PyObject *filename, 109 int lineno, 110 int col_offset); 111 112 PyAPI_FUNC(void) PyErr_RangedSyntaxLocationObject( 113 PyObject *filename, 114 int lineno, 115 int col_offset, 116 int end_lineno, 117 int end_col_offset); 118 119 PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject( 120 PyObject *filename, 121 int lineno); 122 123 PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFunc( 124 const char *func, 125 const char *message); 126 127 PyAPI_FUNC(void) PyErr_FormatUnraisable(const char *, ...); 128 129 PyAPI_DATA(PyObject *) PyExc_PythonFinalizationError; 130 131 #define Py_FatalError(message) _Py_FatalErrorFunc(__func__, (message)) 132