1 #ifndef Py_INTERNAL_PYERRORS_H
2 #define Py_INTERNAL_PYERRORS_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #ifndef Py_BUILD_CORE
8 # error "this header requires Py_BUILD_CORE define"
9 #endif
10
_PyErr_Occurred(PyThreadState * tstate)11 static inline PyObject* _PyErr_Occurred(PyThreadState *tstate)
12 {
13 assert(tstate != NULL);
14 return tstate->curexc_type;
15 }
16
_PyErr_ClearExcState(_PyErr_StackItem * exc_state)17 static inline void _PyErr_ClearExcState(_PyErr_StackItem *exc_state)
18 {
19 PyObject *t, *v, *tb;
20 t = exc_state->exc_type;
21 v = exc_state->exc_value;
22 tb = exc_state->exc_traceback;
23 exc_state->exc_type = NULL;
24 exc_state->exc_value = NULL;
25 exc_state->exc_traceback = NULL;
26 Py_XDECREF(t);
27 Py_XDECREF(v);
28 Py_XDECREF(tb);
29 }
30
31
32 PyAPI_FUNC(void) _PyErr_Fetch(
33 PyThreadState *tstate,
34 PyObject **type,
35 PyObject **value,
36 PyObject **traceback);
37
38 PyAPI_FUNC(int) _PyErr_ExceptionMatches(
39 PyThreadState *tstate,
40 PyObject *exc);
41
42 PyAPI_FUNC(void) _PyErr_Restore(
43 PyThreadState *tstate,
44 PyObject *type,
45 PyObject *value,
46 PyObject *traceback);
47
48 PyAPI_FUNC(void) _PyErr_SetObject(
49 PyThreadState *tstate,
50 PyObject *type,
51 PyObject *value);
52
53 PyAPI_FUNC(void) _PyErr_ChainStackItem(
54 _PyErr_StackItem *exc_info);
55
56 PyAPI_FUNC(void) _PyErr_Clear(PyThreadState *tstate);
57
58 PyAPI_FUNC(void) _PyErr_SetNone(PyThreadState *tstate, PyObject *exception);
59
60 PyAPI_FUNC(PyObject *) _PyErr_NoMemory(PyThreadState *tstate);
61
62 PyAPI_FUNC(void) _PyErr_SetString(
63 PyThreadState *tstate,
64 PyObject *exception,
65 const char *string);
66
67 PyAPI_FUNC(PyObject *) _PyErr_Format(
68 PyThreadState *tstate,
69 PyObject *exception,
70 const char *format,
71 ...);
72
73 PyAPI_FUNC(void) _PyErr_NormalizeException(
74 PyThreadState *tstate,
75 PyObject **exc,
76 PyObject **val,
77 PyObject **tb);
78
79 PyAPI_FUNC(PyObject *) _PyErr_FormatFromCauseTstate(
80 PyThreadState *tstate,
81 PyObject *exception,
82 const char *format,
83 ...);
84
85 PyAPI_FUNC(int) _PyErr_CheckSignalsTstate(PyThreadState *tstate);
86
87 #ifdef __cplusplus
88 }
89 #endif
90 #endif /* !Py_INTERNAL_PYERRORS_H */
91