Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 1 | #ifndef Py_ERRORS_H |
| 2 | #define Py_ERRORS_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 7 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 8 | /* Error handling definitions */ |
| 9 | |
Fred Drake | d5c84ed | 2000-07-08 17:25:55 +0000 | [diff] [blame] | 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 *); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 17 | |
Barry Warsaw | c0dc92a | 1997-08-22 21:22:58 +0000 | [diff] [blame] | 18 | /* Error testing and normalization */ |
Fred Drake | d5c84ed | 2000-07-08 17:25:55 +0000 | [diff] [blame] | 19 | DL_IMPORT(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *); |
| 20 | DL_IMPORT(int) PyErr_ExceptionMatches(PyObject *); |
| 21 | DL_IMPORT(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); |
Barry Warsaw | c0dc92a | 1997-08-22 21:22:58 +0000 | [diff] [blame] | 22 | |
| 23 | |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 24 | /* Predefined exceptions */ |
Guido van Rossum | 5c600e1 | 1990-10-14 20:00:25 +0000 | [diff] [blame] | 25 | |
Guido van Rossum | 0474832 | 1997-09-16 18:43:15 +0000 | [diff] [blame] | 26 | extern DL_IMPORT(PyObject *) PyExc_Exception; |
Barry Warsaw | 392d827 | 1997-08-29 21:56:07 +0000 | [diff] [blame] | 27 | extern DL_IMPORT(PyObject *) PyExc_StandardError; |
Barry Warsaw | 65349a3 | 1997-09-16 21:50:36 +0000 | [diff] [blame] | 28 | extern DL_IMPORT(PyObject *) PyExc_ArithmeticError; |
Barry Warsaw | 392d827 | 1997-08-29 21:56:07 +0000 | [diff] [blame] | 29 | extern DL_IMPORT(PyObject *) PyExc_LookupError; |
| 30 | |
Guido van Rossum | 6fa4466 | 1997-04-02 05:22:53 +0000 | [diff] [blame] | 31 | extern DL_IMPORT(PyObject *) PyExc_AssertionError; |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 32 | extern DL_IMPORT(PyObject *) PyExc_AttributeError; |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 33 | extern DL_IMPORT(PyObject *) PyExc_EOFError; |
Guido van Rossum | 7d4266e | 1997-02-14 22:53:12 +0000 | [diff] [blame] | 34 | extern DL_IMPORT(PyObject *) PyExc_FloatingPointError; |
Barry Warsaw | 62a21a2 | 1998-07-23 15:57:34 +0000 | [diff] [blame] | 35 | extern DL_IMPORT(PyObject *) PyExc_EnvironmentError; |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 36 | extern DL_IMPORT(PyObject *) PyExc_IOError; |
Barry Warsaw | 62a21a2 | 1998-07-23 15:57:34 +0000 | [diff] [blame] | 37 | extern DL_IMPORT(PyObject *) PyExc_OSError; |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 38 | extern DL_IMPORT(PyObject *) PyExc_ImportError; |
| 39 | extern DL_IMPORT(PyObject *) PyExc_IndexError; |
| 40 | extern DL_IMPORT(PyObject *) PyExc_KeyError; |
| 41 | extern DL_IMPORT(PyObject *) PyExc_KeyboardInterrupt; |
| 42 | extern DL_IMPORT(PyObject *) PyExc_MemoryError; |
| 43 | extern DL_IMPORT(PyObject *) PyExc_NameError; |
| 44 | extern DL_IMPORT(PyObject *) PyExc_OverflowError; |
| 45 | extern DL_IMPORT(PyObject *) PyExc_RuntimeError; |
Barry Warsaw | d052ff0 | 1998-12-01 18:34:01 +0000 | [diff] [blame] | 46 | extern DL_IMPORT(PyObject *) PyExc_NotImplementedError; |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 47 | extern DL_IMPORT(PyObject *) PyExc_SyntaxError; |
Fred Drake | d5c84ed | 2000-07-08 17:25:55 +0000 | [diff] [blame] | 48 | extern DL_IMPORT(PyObject *) PyExc_IndentationError; |
| 49 | extern DL_IMPORT(PyObject *) PyExc_TabError; |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 50 | extern DL_IMPORT(PyObject *) PyExc_SystemError; |
| 51 | extern DL_IMPORT(PyObject *) PyExc_SystemExit; |
| 52 | extern DL_IMPORT(PyObject *) PyExc_TypeError; |
Guido van Rossum | 8746082 | 1999-06-22 14:47:32 +0000 | [diff] [blame] | 53 | extern DL_IMPORT(PyObject *) PyExc_UnboundLocalError; |
Guido van Rossum | 99cc971 | 2000-03-10 22:33:32 +0000 | [diff] [blame] | 54 | extern DL_IMPORT(PyObject *) PyExc_UnicodeError; |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 55 | extern DL_IMPORT(PyObject *) PyExc_ValueError; |
| 56 | extern DL_IMPORT(PyObject *) PyExc_ZeroDivisionError; |
Guido van Rossum | db0c9f7 | 2000-02-17 15:17:18 +0000 | [diff] [blame] | 57 | #ifdef MS_WINDOWS |
| 58 | extern DL_IMPORT(PyObject *) PyExc_WindowsError; |
| 59 | #endif |
Guido van Rossum | 3e55cb6 | 1990-10-21 22:09:30 +0000 | [diff] [blame] | 60 | |
Barry Warsaw | 392d827 | 1997-08-29 21:56:07 +0000 | [diff] [blame] | 61 | extern DL_IMPORT(PyObject *) PyExc_MemoryErrorInst; |
| 62 | |
Guido van Rossum | 3fc3037 | 2000-12-15 21:57:34 +0000 | [diff] [blame] | 63 | /* Predefined warning categories */ |
| 64 | extern DL_IMPORT(PyObject *) PyExc_Warning; |
| 65 | extern DL_IMPORT(PyObject *) PyExc_UserWarning; |
| 66 | extern DL_IMPORT(PyObject *) PyExc_DeprecationWarning; |
| 67 | extern DL_IMPORT(PyObject *) PyExc_SyntaxWarning; |
| 68 | extern DL_IMPORT(PyObject *) PyExc_RuntimeWarning; |
| 69 | |
Barry Warsaw | 392d827 | 1997-08-29 21:56:07 +0000 | [diff] [blame] | 70 | |
Guido van Rossum | 5c600e1 | 1990-10-14 20:00:25 +0000 | [diff] [blame] | 71 | /* Convenience functions */ |
| 72 | |
Fred Drake | d5c84ed | 2000-07-08 17:25:55 +0000 | [diff] [blame] | 73 | extern DL_IMPORT(int) PyErr_BadArgument(void); |
| 74 | extern DL_IMPORT(PyObject *) PyErr_NoMemory(void); |
| 75 | extern DL_IMPORT(PyObject *) PyErr_SetFromErrno(PyObject *); |
| 76 | extern DL_IMPORT(PyObject *) PyErr_SetFromErrnoWithFilename(PyObject *, char *); |
| 77 | extern DL_IMPORT(PyObject *) PyErr_Format(PyObject *, const char *, ...); |
Guido van Rossum | db0c9f7 | 2000-02-17 15:17:18 +0000 | [diff] [blame] | 78 | #ifdef MS_WINDOWS |
| 79 | extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErrWithFilename(int, const char *); |
| 80 | extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErr(int); |
| 81 | #endif |
Guido van Rossum | 3e55cb6 | 1990-10-21 22:09:30 +0000 | [diff] [blame] | 82 | |
Fred Drake | 6d63adf | 2000-08-24 22:38:39 +0000 | [diff] [blame] | 83 | /* Export the old function so that the existing API remains available: */ |
Fred Drake | d5c84ed | 2000-07-08 17:25:55 +0000 | [diff] [blame] | 84 | extern DL_IMPORT(void) PyErr_BadInternalCall(void); |
Fred Drake | 6d63adf | 2000-08-24 22:38:39 +0000 | [diff] [blame] | 85 | extern DL_IMPORT(void) _PyErr_BadInternalCall(char *filename, int lineno); |
| 86 | /* Mask the old API with a call to the new API for code compiled under |
| 87 | Python 2.0: */ |
| 88 | #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 89 | |
Guido van Rossum | 2d2c344 | 1997-09-16 21:50:37 +0000 | [diff] [blame] | 90 | /* Function to create a new exception */ |
Fred Drake | d5c84ed | 2000-07-08 17:25:55 +0000 | [diff] [blame] | 91 | DL_IMPORT(PyObject *) PyErr_NewException(char *name, PyObject *base, |
| 92 | PyObject *dict); |
Jeremy Hylton | b709df3 | 2000-09-01 02:47:25 +0000 | [diff] [blame] | 93 | extern DL_IMPORT(void) PyErr_WriteUnraisable(PyObject *); |
Guido van Rossum | 2d2c344 | 1997-09-16 21:50:37 +0000 | [diff] [blame] | 94 | |
Guido van Rossum | 3fc3037 | 2000-12-15 21:57:34 +0000 | [diff] [blame] | 95 | /* Issue a warning or exception */ |
| 96 | extern DL_IMPORT(int) PyErr_Warn(PyObject *, char *); |
Guido van Rossum | 1bcb7e9 | 2001-02-28 21:44:20 +0000 | [diff] [blame] | 97 | extern DL_IMPORT(int) PyErr_WarnExplicit(PyObject *, char *, |
| 98 | char *, int, char *, PyObject *); |
Guido van Rossum | 3fc3037 | 2000-12-15 21:57:34 +0000 | [diff] [blame] | 99 | |
Barry Warsaw | f3f41a9 | 1997-01-03 00:15:03 +0000 | [diff] [blame] | 100 | /* In sigcheck.c or signalmodule.c */ |
Fred Drake | d5c84ed | 2000-07-08 17:25:55 +0000 | [diff] [blame] | 101 | extern DL_IMPORT(int) PyErr_CheckSignals(void); |
| 102 | extern DL_IMPORT(void) PyErr_SetInterrupt(void); |
Jeremy Hylton | ad3d3f2 | 2001-02-28 17:47:12 +0000 | [diff] [blame] | 103 | |
| 104 | /* Support for adding program text to SyntaxErrors */ |
| 105 | extern DL_IMPORT(void) PyErr_SyntaxLocation(char *, int); |
| 106 | extern DL_IMPORT(PyObject *) PyErr_ProgramText(char *, int); |
Barry Warsaw | f3f41a9 | 1997-01-03 00:15:03 +0000 | [diff] [blame] | 107 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 108 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 109 | #ifdef __cplusplus |
| 110 | } |
| 111 | #endif |
| 112 | #endif /* !Py_ERRORS_H */ |