2019-05-24 12:01:38 -03:00
|
|
|
#ifndef Py_INTERNAL_PYERRORS_H
|
|
|
|
#define Py_INTERNAL_PYERRORS_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef Py_BUILD_CORE
|
|
|
|
# error "this header requires Py_BUILD_CORE define"
|
|
|
|
#endif
|
|
|
|
|
2021-12-09 15:59:26 -04:00
|
|
|
|
2023-07-03 07:48:50 -03:00
|
|
|
/* Error handling definitions */
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern _PyErr_StackItem* _PyErr_GetTopmostException(PyThreadState *tstate);
|
|
|
|
extern PyObject* _PyErr_GetHandledException(PyThreadState *);
|
|
|
|
extern void _PyErr_SetHandledException(PyThreadState *, PyObject *);
|
|
|
|
extern void _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, PyObject **);
|
|
|
|
|
2023-08-29 00:13:41 -03:00
|
|
|
// Export for '_testinternalcapi' shared extension
|
|
|
|
PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *);
|
|
|
|
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
// Like PyErr_Format(), but saves current exception as __context__ and
|
|
|
|
// __cause__.
|
|
|
|
// Export for '_sqlite3' shared extension.
|
|
|
|
PyAPI_FUNC(PyObject*) _PyErr_FormatFromCause(
|
2023-07-03 07:48:50 -03:00
|
|
|
PyObject *exception,
|
|
|
|
const char *format, /* ASCII-encoded string */
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern int _PyException_AddNote(
|
2023-07-03 07:48:50 -03:00
|
|
|
PyObject *exc,
|
|
|
|
PyObject *note);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern int _PyErr_CheckSignals(void);
|
2023-07-03 07:48:50 -03:00
|
|
|
|
|
|
|
/* Support for adding program text to SyntaxErrors */
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
// Export for test_peg_generator
|
|
|
|
PyAPI_FUNC(PyObject*) _PyErr_ProgramDecodedTextObject(
|
2023-07-03 07:48:50 -03:00
|
|
|
PyObject *filename,
|
|
|
|
int lineno,
|
|
|
|
const char* encoding);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern PyObject* _PyUnicodeTranslateError_Create(
|
2023-07-03 07:48:50 -03:00
|
|
|
PyObject *object,
|
|
|
|
Py_ssize_t start,
|
|
|
|
Py_ssize_t end,
|
|
|
|
const char *reason /* UTF-8 encoded string */
|
|
|
|
);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _Py_NO_RETURN _Py_FatalErrorFormat(
|
2023-07-03 07:48:50 -03:00
|
|
|
const char *func,
|
|
|
|
const char *format,
|
|
|
|
...);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern PyObject* _PyErr_SetImportErrorWithNameFrom(
|
2023-07-03 07:48:50 -03:00
|
|
|
PyObject *,
|
|
|
|
PyObject *,
|
|
|
|
PyObject *,
|
|
|
|
PyObject *);
|
|
|
|
|
|
|
|
|
2021-12-09 15:59:26 -04:00
|
|
|
/* runtime lifecycle */
|
|
|
|
|
|
|
|
extern PyStatus _PyErr_InitTypes(PyInterpreterState *);
|
2022-01-20 20:42:25 -04:00
|
|
|
extern void _PyErr_FiniTypes(PyInterpreterState *);
|
2021-12-09 15:59:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* other API */
|
|
|
|
|
2019-05-24 12:01:38 -03:00
|
|
|
static inline PyObject* _PyErr_Occurred(PyThreadState *tstate)
|
|
|
|
{
|
2019-11-07 07:42:07 -04:00
|
|
|
assert(tstate != NULL);
|
2023-02-08 05:31:12 -04:00
|
|
|
if (tstate->current_exception == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return (PyObject *)Py_TYPE(tstate->current_exception);
|
2019-05-24 12:01:38 -03:00
|
|
|
}
|
|
|
|
|
2020-05-18 02:47:31 -03:00
|
|
|
static inline void _PyErr_ClearExcState(_PyErr_StackItem *exc_state)
|
|
|
|
{
|
2021-12-17 10:46:22 -04:00
|
|
|
Py_CLEAR(exc_state->exc_value);
|
2020-05-18 02:47:31 -03:00
|
|
|
}
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern PyObject* _PyErr_StackItemToExcInfoTuple(
|
2021-11-25 05:41:28 -04:00
|
|
|
_PyErr_StackItem *err_info);
|
2019-05-24 12:01:38 -03:00
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _PyErr_Fetch(
|
2019-05-24 12:01:38 -03:00
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject **type,
|
|
|
|
PyObject **value,
|
|
|
|
PyObject **traceback);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern PyObject* _PyErr_GetRaisedException(PyThreadState *tstate);
|
2023-02-08 05:31:12 -04:00
|
|
|
|
2024-02-29 12:11:28 -04:00
|
|
|
PyAPI_FUNC(int) _PyErr_ExceptionMatches(
|
2019-05-24 12:01:38 -03:00
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject *exc);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _PyErr_SetRaisedException(PyThreadState *tstate, PyObject *exc);
|
2023-02-08 05:31:12 -04:00
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _PyErr_Restore(
|
2019-05-24 12:01:38 -03:00
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject *type,
|
|
|
|
PyObject *value,
|
|
|
|
PyObject *traceback);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _PyErr_SetObject(
|
2019-05-24 12:01:38 -03:00
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject *type,
|
|
|
|
PyObject *value);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _PyErr_ChainStackItem(void);
|
2020-05-18 02:47:31 -03:00
|
|
|
|
2024-02-29 12:11:28 -04:00
|
|
|
PyAPI_FUNC(void) _PyErr_Clear(PyThreadState *tstate);
|
2019-05-24 12:01:38 -03:00
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _PyErr_SetNone(PyThreadState *tstate, PyObject *exception);
|
2019-05-24 12:01:38 -03:00
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern PyObject* _PyErr_NoMemory(PyThreadState *tstate);
|
2019-06-13 17:41:23 -03:00
|
|
|
|
2024-02-29 12:11:28 -04:00
|
|
|
PyAPI_FUNC(void) _PyErr_SetString(
|
2019-05-24 12:01:38 -03:00
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject *exception,
|
|
|
|
const char *string);
|
|
|
|
|
2024-02-29 12:11:28 -04:00
|
|
|
PyAPI_FUNC(PyObject*) _PyErr_Format(
|
2019-05-24 12:01:38 -03:00
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject *exception,
|
|
|
|
const char *format,
|
|
|
|
...);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _PyErr_NormalizeException(
|
2019-05-24 12:01:38 -03:00
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject **exc,
|
|
|
|
PyObject **val,
|
|
|
|
PyObject **tb);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern PyObject* _PyErr_FormatFromCauseTstate(
|
2019-11-04 20:22:12 -04:00
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject *exception,
|
|
|
|
const char *format,
|
|
|
|
...);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern PyObject* _PyExc_CreateExceptionGroup(
|
2021-12-14 12:48:15 -04:00
|
|
|
const char *msg,
|
|
|
|
PyObject *excs);
|
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern PyObject* _PyExc_PrepReraiseStar(
|
2022-01-02 19:22:42 -04:00
|
|
|
PyObject *orig,
|
|
|
|
PyObject *excs);
|
2021-12-14 12:48:15 -04:00
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern int _PyErr_CheckSignalsTstate(PyThreadState *tstate);
|
2020-03-26 18:28:11 -03:00
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
extern void _Py_DumpExtensionModules(int fd, PyInterpreterState *interp);
|
2023-08-17 15:39:42 -03:00
|
|
|
extern PyObject* _Py_CalculateSuggestions(PyObject *dir, PyObject *name);
|
2021-04-13 22:36:07 -03:00
|
|
|
extern PyObject* _Py_Offer_Suggestions(PyObject* exception);
|
2023-08-24 12:28:35 -03:00
|
|
|
|
2023-07-24 22:49:28 -03:00
|
|
|
// Export for '_testinternalcapi' shared extension
|
2021-05-03 12:47:27 -03:00
|
|
|
PyAPI_FUNC(Py_ssize_t) _Py_UTF8_Edit_Cost(PyObject *str_a, PyObject *str_b,
|
|
|
|
Py_ssize_t max_cost);
|
2021-04-13 22:36:07 -03:00
|
|
|
|
2023-04-11 07:53:06 -03:00
|
|
|
void _PyErr_FormatNote(const char *format, ...);
|
|
|
|
|
2023-08-31 08:53:19 -03:00
|
|
|
/* Context manipulation (PEP 3134) */
|
|
|
|
|
|
|
|
Py_DEPRECATED(3.12) extern void _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
|
|
|
|
|
|
|
|
// Export for '_zoneinfo' shared extension
|
|
|
|
PyAPI_FUNC(void) _PyErr_ChainExceptions1(PyObject *);
|
|
|
|
|
2019-05-24 12:01:38 -03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_INTERNAL_PYERRORS_H */
|