8 /* Error handling definitions */
10 DL_IMPORT(void) PyErr_SetNone(PyObject
*);
11 DL_IMPORT(void) PyErr_SetObject(PyObject
*, PyObject
*);
12 DL_IMPORT(void) PyErr_SetString(PyObject
*, const char *);
13 DL_IMPORT(PyObject
*) PyErr_Occurred(void);
14 DL_IMPORT(void) PyErr_Clear(void);
15 DL_IMPORT(void) PyErr_Fetch(PyObject
**, PyObject
**, PyObject
**);
16 DL_IMPORT(void) PyErr_Restore(PyObject
*, PyObject
*, PyObject
*);
18 /* Error testing and normalization */
19 DL_IMPORT(int) PyErr_GivenExceptionMatches(PyObject
*, PyObject
*);
20 DL_IMPORT(int) PyErr_ExceptionMatches(PyObject
*);
21 DL_IMPORT(void) PyErr_NormalizeException(PyObject
**, PyObject
**, PyObject
**);
24 /* Predefined exceptions */
26 extern DL_IMPORT(PyObject
*) PyExc_Exception
;
27 extern DL_IMPORT(PyObject
*) PyExc_StopIteration
;
28 extern DL_IMPORT(PyObject
*) PyExc_StandardError
;
29 extern DL_IMPORT(PyObject
*) PyExc_ArithmeticError
;
30 extern DL_IMPORT(PyObject
*) PyExc_LookupError
;
32 extern DL_IMPORT(PyObject
*) PyExc_AssertionError
;
33 extern DL_IMPORT(PyObject
*) PyExc_AttributeError
;
34 extern DL_IMPORT(PyObject
*) PyExc_EOFError
;
35 extern DL_IMPORT(PyObject
*) PyExc_FloatingPointError
;
36 extern DL_IMPORT(PyObject
*) PyExc_EnvironmentError
;
37 extern DL_IMPORT(PyObject
*) PyExc_IOError
;
38 extern DL_IMPORT(PyObject
*) PyExc_OSError
;
39 extern DL_IMPORT(PyObject
*) PyExc_ImportError
;
40 extern DL_IMPORT(PyObject
*) PyExc_IndexError
;
41 extern DL_IMPORT(PyObject
*) PyExc_KeyError
;
42 extern DL_IMPORT(PyObject
*) PyExc_KeyboardInterrupt
;
43 extern DL_IMPORT(PyObject
*) PyExc_MemoryError
;
44 extern DL_IMPORT(PyObject
*) PyExc_NameError
;
45 extern DL_IMPORT(PyObject
*) PyExc_OverflowError
;
46 extern DL_IMPORT(PyObject
*) PyExc_RuntimeError
;
47 extern DL_IMPORT(PyObject
*) PyExc_NotImplementedError
;
48 extern DL_IMPORT(PyObject
*) PyExc_SyntaxError
;
49 extern DL_IMPORT(PyObject
*) PyExc_IndentationError
;
50 extern DL_IMPORT(PyObject
*) PyExc_TabError
;
51 extern DL_IMPORT(PyObject
*) PyExc_ReferenceError
;
52 extern DL_IMPORT(PyObject
*) PyExc_SystemError
;
53 extern DL_IMPORT(PyObject
*) PyExc_SystemExit
;
54 extern DL_IMPORT(PyObject
*) PyExc_TypeError
;
55 extern DL_IMPORT(PyObject
*) PyExc_UnboundLocalError
;
56 extern DL_IMPORT(PyObject
*) PyExc_UnicodeError
;
57 extern DL_IMPORT(PyObject
*) PyExc_ValueError
;
58 extern DL_IMPORT(PyObject
*) PyExc_ZeroDivisionError
;
60 extern DL_IMPORT(PyObject
*) PyExc_WindowsError
;
63 extern DL_IMPORT(PyObject
*) PyExc_MemoryErrorInst
;
65 /* Predefined warning categories */
66 extern DL_IMPORT(PyObject
*) PyExc_Warning
;
67 extern DL_IMPORT(PyObject
*) PyExc_UserWarning
;
68 extern DL_IMPORT(PyObject
*) PyExc_DeprecationWarning
;
69 extern DL_IMPORT(PyObject
*) PyExc_PendingDeprecationWarning
;
70 extern DL_IMPORT(PyObject
*) PyExc_SyntaxWarning
;
71 extern DL_IMPORT(PyObject
*) PyExc_OverflowWarning
;
72 extern DL_IMPORT(PyObject
*) PyExc_RuntimeWarning
;
75 /* Convenience functions */
77 extern DL_IMPORT(int) PyErr_BadArgument(void);
78 extern DL_IMPORT(PyObject
*) PyErr_NoMemory(void);
79 extern DL_IMPORT(PyObject
*) PyErr_SetFromErrno(PyObject
*);
80 extern DL_IMPORT(PyObject
*) PyErr_SetFromErrnoWithFilename(PyObject
*, char *);
81 extern DL_IMPORT(PyObject
*) PyErr_Format(PyObject
*, const char *, ...)
82 __attribute__((format(printf
, 2, 3)));
84 extern DL_IMPORT(PyObject
*) PyErr_SetFromWindowsErrWithFilename(int, const char *);
85 extern DL_IMPORT(PyObject
*) PyErr_SetFromWindowsErr(int);
88 /* Export the old function so that the existing API remains available: */
89 extern DL_IMPORT(void) PyErr_BadInternalCall(void);
90 extern DL_IMPORT(void) _PyErr_BadInternalCall(char *filename
, int lineno
);
91 /* Mask the old API with a call to the new API for code compiled under
93 #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
95 /* Function to create a new exception */
96 DL_IMPORT(PyObject
*) PyErr_NewException(char *name
, PyObject
*base
,
98 extern DL_IMPORT(void) PyErr_WriteUnraisable(PyObject
*);
100 /* Issue a warning or exception */
101 extern DL_IMPORT(int) PyErr_Warn(PyObject
*, char *);
102 extern DL_IMPORT(int) PyErr_WarnExplicit(PyObject
*, char *,
103 char *, int, char *, PyObject
*);
105 /* In sigcheck.c or signalmodule.c */
106 extern DL_IMPORT(int) PyErr_CheckSignals(void);
107 extern DL_IMPORT(void) PyErr_SetInterrupt(void);
109 /* Support for adding program text to SyntaxErrors */
110 extern DL_IMPORT(void) PyErr_SyntaxLocation(char *, int);
111 extern DL_IMPORT(PyObject
*) PyErr_ProgramText(char *, int);
113 /* These APIs aren't really part of the error implementation, but
114 often needed to format error messages; the native C lib APIs are
115 not available on all platforms, which is why we provide emulations
116 for those platforms in Python/mysnprintf.c,
117 WARNING: The return value of snprintf varies across platforms; do
118 not rely on any particular behavior; eventually the C99 defn may
121 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
122 # define HAVE_SNPRINTF
123 # define snprintf _snprintf
124 # define vsnprintf _vsnprintf
128 extern DL_IMPORT(int) PyOS_snprintf(char *str
, size_t size
, const char *format
, ...)
129 __attribute__((format(printf
, 3, 4)));
130 extern DL_IMPORT(int) PyOS_vsnprintf(char *str
, size_t size
, const char *format
, va_list va
)
131 __attribute__((format(printf
, 3, 0)));
136 #endif /* !Py_ERRORS_H */