jpayne@69
|
1 #ifndef Py_CPYTHON_ERRORS_H
|
jpayne@69
|
2 # error "this header file must not be included directly"
|
jpayne@69
|
3 #endif
|
jpayne@69
|
4
|
jpayne@69
|
5 #ifdef __cplusplus
|
jpayne@69
|
6 extern "C" {
|
jpayne@69
|
7 #endif
|
jpayne@69
|
8
|
jpayne@69
|
9 /* Error objects */
|
jpayne@69
|
10
|
jpayne@69
|
11 /* PyException_HEAD defines the initial segment of every exception class. */
|
jpayne@69
|
12 #define PyException_HEAD PyObject_HEAD PyObject *dict;\
|
jpayne@69
|
13 PyObject *args; PyObject *traceback;\
|
jpayne@69
|
14 PyObject *context; PyObject *cause;\
|
jpayne@69
|
15 char suppress_context;
|
jpayne@69
|
16
|
jpayne@69
|
17 typedef struct {
|
jpayne@69
|
18 PyException_HEAD
|
jpayne@69
|
19 } PyBaseExceptionObject;
|
jpayne@69
|
20
|
jpayne@69
|
21 typedef struct {
|
jpayne@69
|
22 PyException_HEAD
|
jpayne@69
|
23 PyObject *msg;
|
jpayne@69
|
24 PyObject *filename;
|
jpayne@69
|
25 PyObject *lineno;
|
jpayne@69
|
26 PyObject *offset;
|
jpayne@69
|
27 PyObject *text;
|
jpayne@69
|
28 PyObject *print_file_and_line;
|
jpayne@69
|
29 } PySyntaxErrorObject;
|
jpayne@69
|
30
|
jpayne@69
|
31 typedef struct {
|
jpayne@69
|
32 PyException_HEAD
|
jpayne@69
|
33 PyObject *msg;
|
jpayne@69
|
34 PyObject *name;
|
jpayne@69
|
35 PyObject *path;
|
jpayne@69
|
36 } PyImportErrorObject;
|
jpayne@69
|
37
|
jpayne@69
|
38 typedef struct {
|
jpayne@69
|
39 PyException_HEAD
|
jpayne@69
|
40 PyObject *encoding;
|
jpayne@69
|
41 PyObject *object;
|
jpayne@69
|
42 Py_ssize_t start;
|
jpayne@69
|
43 Py_ssize_t end;
|
jpayne@69
|
44 PyObject *reason;
|
jpayne@69
|
45 } PyUnicodeErrorObject;
|
jpayne@69
|
46
|
jpayne@69
|
47 typedef struct {
|
jpayne@69
|
48 PyException_HEAD
|
jpayne@69
|
49 PyObject *code;
|
jpayne@69
|
50 } PySystemExitObject;
|
jpayne@69
|
51
|
jpayne@69
|
52 typedef struct {
|
jpayne@69
|
53 PyException_HEAD
|
jpayne@69
|
54 PyObject *myerrno;
|
jpayne@69
|
55 PyObject *strerror;
|
jpayne@69
|
56 PyObject *filename;
|
jpayne@69
|
57 PyObject *filename2;
|
jpayne@69
|
58 #ifdef MS_WINDOWS
|
jpayne@69
|
59 PyObject *winerror;
|
jpayne@69
|
60 #endif
|
jpayne@69
|
61 Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */
|
jpayne@69
|
62 } PyOSErrorObject;
|
jpayne@69
|
63
|
jpayne@69
|
64 typedef struct {
|
jpayne@69
|
65 PyException_HEAD
|
jpayne@69
|
66 PyObject *value;
|
jpayne@69
|
67 } PyStopIterationObject;
|
jpayne@69
|
68
|
jpayne@69
|
69 /* Compatibility typedefs */
|
jpayne@69
|
70 typedef PyOSErrorObject PyEnvironmentErrorObject;
|
jpayne@69
|
71 #ifdef MS_WINDOWS
|
jpayne@69
|
72 typedef PyOSErrorObject PyWindowsErrorObject;
|
jpayne@69
|
73 #endif
|
jpayne@69
|
74
|
jpayne@69
|
75 /* Error handling definitions */
|
jpayne@69
|
76
|
jpayne@69
|
77 PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *);
|
jpayne@69
|
78 _PyErr_StackItem *_PyErr_GetTopmostException(PyThreadState *tstate);
|
jpayne@69
|
79
|
jpayne@69
|
80 /* Context manipulation (PEP 3134) */
|
jpayne@69
|
81
|
jpayne@69
|
82 PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
|
jpayne@69
|
83
|
jpayne@69
|
84 /* */
|
jpayne@69
|
85
|
jpayne@69
|
86 #define PyExceptionClass_Name(x) (((PyTypeObject*)(x))->tp_name)
|
jpayne@69
|
87
|
jpayne@69
|
88 /* Convenience functions */
|
jpayne@69
|
89
|
jpayne@69
|
90 #ifdef MS_WINDOWS
|
jpayne@69
|
91 Py_DEPRECATED(3.3)
|
jpayne@69
|
92 PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
|
jpayne@69
|
93 PyObject *, const Py_UNICODE *);
|
jpayne@69
|
94 #endif /* MS_WINDOWS */
|
jpayne@69
|
95
|
jpayne@69
|
96 /* Like PyErr_Format(), but saves current exception as __context__ and
|
jpayne@69
|
97 __cause__.
|
jpayne@69
|
98 */
|
jpayne@69
|
99 PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
|
jpayne@69
|
100 PyObject *exception,
|
jpayne@69
|
101 const char *format, /* ASCII-encoded string */
|
jpayne@69
|
102 ...
|
jpayne@69
|
103 );
|
jpayne@69
|
104
|
jpayne@69
|
105 #ifdef MS_WINDOWS
|
jpayne@69
|
106 /* XXX redeclare to use WSTRING */
|
jpayne@69
|
107 Py_DEPRECATED(3.3)
|
jpayne@69
|
108 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
|
jpayne@69
|
109 int, const Py_UNICODE *);
|
jpayne@69
|
110 Py_DEPRECATED(3.3)
|
jpayne@69
|
111 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
jpayne@69
|
112 PyObject *,int, const Py_UNICODE *);
|
jpayne@69
|
113 #endif
|
jpayne@69
|
114
|
jpayne@69
|
115 /* In exceptions.c */
|
jpayne@69
|
116
|
jpayne@69
|
117 /* Helper that attempts to replace the current exception with one of the
|
jpayne@69
|
118 * same type but with a prefix added to the exception text. The resulting
|
jpayne@69
|
119 * exception description looks like:
|
jpayne@69
|
120 *
|
jpayne@69
|
121 * prefix (exc_type: original_exc_str)
|
jpayne@69
|
122 *
|
jpayne@69
|
123 * Only some exceptions can be safely replaced. If the function determines
|
jpayne@69
|
124 * it isn't safe to perform the replacement, it will leave the original
|
jpayne@69
|
125 * unmodified exception in place.
|
jpayne@69
|
126 *
|
jpayne@69
|
127 * Returns a borrowed reference to the new exception (if any), NULL if the
|
jpayne@69
|
128 * existing exception was left in place.
|
jpayne@69
|
129 */
|
jpayne@69
|
130 PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
|
jpayne@69
|
131 const char *prefix_format, /* ASCII-encoded string */
|
jpayne@69
|
132 ...
|
jpayne@69
|
133 );
|
jpayne@69
|
134
|
jpayne@69
|
135 /* In signalmodule.c */
|
jpayne@69
|
136
|
jpayne@69
|
137 int PySignal_SetWakeupFd(int fd);
|
jpayne@69
|
138 PyAPI_FUNC(int) _PyErr_CheckSignals(void);
|
jpayne@69
|
139
|
jpayne@69
|
140 /* Support for adding program text to SyntaxErrors */
|
jpayne@69
|
141
|
jpayne@69
|
142 PyAPI_FUNC(void) PyErr_SyntaxLocationObject(
|
jpayne@69
|
143 PyObject *filename,
|
jpayne@69
|
144 int lineno,
|
jpayne@69
|
145 int col_offset);
|
jpayne@69
|
146
|
jpayne@69
|
147 PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
|
jpayne@69
|
148 PyObject *filename,
|
jpayne@69
|
149 int lineno);
|
jpayne@69
|
150
|
jpayne@69
|
151 /* Create a UnicodeEncodeError object */
|
jpayne@69
|
152 Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
|
jpayne@69
|
153 const char *encoding, /* UTF-8 encoded string */
|
jpayne@69
|
154 const Py_UNICODE *object,
|
jpayne@69
|
155 Py_ssize_t length,
|
jpayne@69
|
156 Py_ssize_t start,
|
jpayne@69
|
157 Py_ssize_t end,
|
jpayne@69
|
158 const char *reason /* UTF-8 encoded string */
|
jpayne@69
|
159 );
|
jpayne@69
|
160
|
jpayne@69
|
161 /* Create a UnicodeTranslateError object */
|
jpayne@69
|
162 Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
|
jpayne@69
|
163 const Py_UNICODE *object,
|
jpayne@69
|
164 Py_ssize_t length,
|
jpayne@69
|
165 Py_ssize_t start,
|
jpayne@69
|
166 Py_ssize_t end,
|
jpayne@69
|
167 const char *reason /* UTF-8 encoded string */
|
jpayne@69
|
168 );
|
jpayne@69
|
169 PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
|
jpayne@69
|
170 PyObject *object,
|
jpayne@69
|
171 Py_ssize_t start,
|
jpayne@69
|
172 Py_ssize_t end,
|
jpayne@69
|
173 const char *reason /* UTF-8 encoded string */
|
jpayne@69
|
174 );
|
jpayne@69
|
175
|
jpayne@69
|
176 PyAPI_FUNC(void) _PyErr_WriteUnraisableMsg(
|
jpayne@69
|
177 const char *err_msg,
|
jpayne@69
|
178 PyObject *obj);
|
jpayne@69
|
179
|
jpayne@69
|
180 #ifdef __cplusplus
|
jpayne@69
|
181 }
|
jpayne@69
|
182 #endif
|