29 #ifdef Py_USING_UNICODE
40 } PyUnicodeErrorObject;
71 } PyWindowsErrorObject;
77 PyAPI_FUNC(
void) PyErr_SetObject(PyObject *, PyObject *);
78 PyAPI_FUNC(
void) PyErr_SetString(PyObject *, const
char *);
81 PyAPI_FUNC(
void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
82 PyAPI_FUNC(
void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
85 #define _PyErr_OCCURRED() PyErr_Occurred()
87 #define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type)
91 PyAPI_FUNC(
int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
92 PyAPI_FUNC(
int) PyErr_ExceptionMatches(PyObject *);
93 PyAPI_FUNC(
void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
97 #define PyExceptionClass_Check(x) \
98 (PyClass_Check((x)) || (PyType_Check((x)) && \
99 PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)))
101 #define PyExceptionInstance_Check(x) \
102 (PyInstance_Check((x)) || \
103 PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS))
105 #define PyExceptionClass_Name(x) \
106 (PyClass_Check((x)) \
107 ? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \
108 : (char *)(((PyTypeObject*)(x))->tp_name))
110 #define PyExceptionInstance_Class(x) \
111 ((PyInstance_Check((x)) \
112 ? (PyObject*)((PyInstanceObject*)(x))->in_class \
113 : (PyObject*)((x)->ob_type)))
129 PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
130 PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
136 PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;
141 PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
143 PyAPI_DATA(PyObject *) PyExc_IndentationError;
149 PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
151 PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
152 PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
153 PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
155 PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
166 PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst;
171 PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;
172 PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
185 PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);
186 PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(
187 PyObject *, PyObject *);
188 PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
189 PyObject *, const
char *);
191 PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
192 PyObject *, const Py_UNICODE *);
195 PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const
char *, ...)
199 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject(
201 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
203 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
204 int, const Py_UNICODE *);
205 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(
int);
206 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
207 PyObject *,
int, PyObject *);
208 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
209 PyObject *,
int, const
char *);
210 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
211 PyObject *,
int, const Py_UNICODE *);
212 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *,
int);
220 #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
225 PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(
226 char *name,
char *
doc, PyObject *base, PyObject *dict);
227 PyAPI_FUNC(
void) PyErr_WriteUnraisable(PyObject *);
238 PyAPI_FUNC(PyObject *) PyErr_ProgramText(const
char *,
int);
240 #ifdef Py_USING_UNICODE
245 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
246 const
char *, const
char *,
Py_ssize_t, Py_ssize_t, Py_ssize_t, const
char *);
249 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
250 const
char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const
char *);
253 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
254 const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const
char *);
257 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
258 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);
261 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);
262 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);
263 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
267 PyAPI_FUNC(
int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);
268 PyAPI_FUNC(
int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);
269 PyAPI_FUNC(
int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);
273 PyAPI_FUNC(
int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);
274 PyAPI_FUNC(
int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);
275 PyAPI_FUNC(
int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);
279 PyAPI_FUNC(
int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);
280 PyAPI_FUNC(
int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);
281 PyAPI_FUNC(
int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);
285 PyAPI_FUNC(
int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);
286 PyAPI_FUNC(
int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);
287 PyAPI_FUNC(
int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);
290 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *);
291 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *);
292 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
296 PyAPI_FUNC(
int) PyUnicodeEncodeError_SetReason(
297 PyObject *, const
char *);
298 PyAPI_FUNC(
int) PyUnicodeDecodeError_SetReason(
299 PyObject *, const
char *);
300 PyAPI_FUNC(
int) PyUnicodeTranslateError_SetReason(
301 PyObject *, const
char *);
313 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
314 # define HAVE_SNPRINTF
315 # define snprintf _snprintf
316 # define vsnprintf _vsnprintf
322 PyAPI_FUNC(
int) PyOS_vsnprintf(
char *str,
size_t size, const
char *format,
va_list va)