This commit was manufactured by cvs2svn to create tag 'r22a4-fork'.
[python/dscho.git] / Include / pyerrors.h
blobd7b76390254b108da1e64de51fe318175c224a3e
1 #ifndef Py_ERRORS_H
2 #define Py_ERRORS_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
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_SystemError;
52 extern DL_IMPORT(PyObject *) PyExc_SystemExit;
53 extern DL_IMPORT(PyObject *) PyExc_TypeError;
54 extern DL_IMPORT(PyObject *) PyExc_UnboundLocalError;
55 extern DL_IMPORT(PyObject *) PyExc_UnicodeError;
56 extern DL_IMPORT(PyObject *) PyExc_ValueError;
57 extern DL_IMPORT(PyObject *) PyExc_ZeroDivisionError;
58 #ifdef MS_WINDOWS
59 extern DL_IMPORT(PyObject *) PyExc_WindowsError;
60 #endif
62 extern DL_IMPORT(PyObject *) PyExc_MemoryErrorInst;
64 /* Predefined warning categories */
65 extern DL_IMPORT(PyObject *) PyExc_Warning;
66 extern DL_IMPORT(PyObject *) PyExc_UserWarning;
67 extern DL_IMPORT(PyObject *) PyExc_DeprecationWarning;
68 extern DL_IMPORT(PyObject *) PyExc_SyntaxWarning;
69 extern DL_IMPORT(PyObject *) PyExc_OverflowWarning;
70 extern DL_IMPORT(PyObject *) PyExc_RuntimeWarning;
73 /* Convenience functions */
75 extern DL_IMPORT(int) PyErr_BadArgument(void);
76 extern DL_IMPORT(PyObject *) PyErr_NoMemory(void);
77 extern DL_IMPORT(PyObject *) PyErr_SetFromErrno(PyObject *);
78 extern DL_IMPORT(PyObject *) PyErr_SetFromErrnoWithFilename(PyObject *, char *);
79 extern DL_IMPORT(PyObject *) PyErr_Format(PyObject *, const char *, ...);
80 #ifdef MS_WINDOWS
81 extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErrWithFilename(int, const char *);
82 extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErr(int);
83 #endif
85 /* Export the old function so that the existing API remains available: */
86 extern DL_IMPORT(void) PyErr_BadInternalCall(void);
87 extern DL_IMPORT(void) _PyErr_BadInternalCall(char *filename, int lineno);
88 /* Mask the old API with a call to the new API for code compiled under
89 Python 2.0: */
90 #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
92 /* Function to create a new exception */
93 DL_IMPORT(PyObject *) PyErr_NewException(char *name, PyObject *base,
94 PyObject *dict);
95 extern DL_IMPORT(void) PyErr_WriteUnraisable(PyObject *);
97 /* Issue a warning or exception */
98 extern DL_IMPORT(int) PyErr_Warn(PyObject *, char *);
99 extern DL_IMPORT(int) PyErr_WarnExplicit(PyObject *, char *,
100 char *, int, char *, PyObject *);
102 /* In sigcheck.c or signalmodule.c */
103 extern DL_IMPORT(int) PyErr_CheckSignals(void);
104 extern DL_IMPORT(void) PyErr_SetInterrupt(void);
106 /* Support for adding program text to SyntaxErrors */
107 extern DL_IMPORT(void) PyErr_SyntaxLocation(char *, int);
108 extern DL_IMPORT(PyObject *) PyErr_ProgramText(char *, int);
110 /* These APIs aren't really part of the error implementation, but
111 often needed to format error messages; the native C lib APIs are
112 not available on all platforms, which is why we provide emulations
113 for those platforms in Python/mysnprintf.c */
114 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
115 # define HAVE_SNPRINTF
116 # define snprintf _snprintf
117 # define vsnprintf _vsnprintf
118 #endif
120 /* Always enable the fallback solution during the 2.2.0 alpha cycle
121 for enhanced testing */
122 #if PY_VERSION_HEX < 0x020200B0
123 # undef HAVE_SNPRINTF
124 #endif
126 #ifndef HAVE_SNPRINTF
127 #include <stdarg.h>
128 extern DL_IMPORT(int) PyOS_snprintf(char *str, size_t size, const char *format, ...);
129 extern DL_IMPORT(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va);
130 #else
131 # define PyOS_vsnprintf vsnprintf
132 # define PyOS_snprintf snprintf
133 #endif
135 #ifdef __cplusplus
137 #endif
138 #endif /* !Py_ERRORS_H */