Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
pyerrors.h336 linesDownload Raw Back to include
1// Error handling definitions2 3#ifndef Py_ERRORS_H4#define Py_ERRORS_H5#ifdef __cplusplus6extern "C" {7#endif8 9PyAPI_FUNC(void) PyErr_SetNone(PyObject *);10PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);11PyAPI_FUNC(void) PyErr_SetString(12    PyObject *exception,13    const char *string   /* decoded from utf-8 */14    );15PyAPI_FUNC(PyObject *) PyErr_Occurred(void);16PyAPI_FUNC(void) PyErr_Clear(void);17PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);18PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);19PyAPI_FUNC(PyObject *) PyErr_GetRaisedException(void);20PyAPI_FUNC(void) PyErr_SetRaisedException(PyObject *);21#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b000022PyAPI_FUNC(PyObject*) PyErr_GetHandledException(void);23PyAPI_FUNC(void) PyErr_SetHandledException(PyObject *);24#endif25#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0303000026PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **);27PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);28#endif29 30/* Defined in Python/pylifecycle.c31 32   The Py_FatalError() function is replaced with a macro which logs33   automatically the name of the current function, unless the Py_LIMITED_API34   macro is defined. */35PyAPI_FUNC(void) _Py_NO_RETURN Py_FatalError(const char *message);36 37/* Error testing and normalization */38PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);39PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *);40PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);41 42/* Traceback manipulation (PEP 3134) */43PyAPI_FUNC(int) PyException_SetTraceback(PyObject *, PyObject *);44PyAPI_FUNC(PyObject *) PyException_GetTraceback(PyObject *);45 46/* Cause manipulation (PEP 3134) */47PyAPI_FUNC(PyObject *) PyException_GetCause(PyObject *);48PyAPI_FUNC(void) PyException_SetCause(PyObject *, PyObject *);49 50/* Context manipulation (PEP 3134) */51PyAPI_FUNC(PyObject *) PyException_GetContext(PyObject *);52PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);53 54 55PyAPI_FUNC(PyObject *) PyException_GetArgs(PyObject *);56PyAPI_FUNC(void) PyException_SetArgs(PyObject *, PyObject *);57 58/* */59 60#define PyExceptionClass_Check(x)                                       \61    (PyType_Check((x)) &&                                               \62     PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))63 64#define PyExceptionInstance_Check(x)                    \65    PyType_FastSubclass(Py_TYPE(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)66 67PyAPI_FUNC(const char *) PyExceptionClass_Name(PyObject *);68 69#define PyExceptionInstance_Class(x) _PyObject_CAST(Py_TYPE(x))70 71#define _PyBaseExceptionGroup_Check(x)                   \72    PyObject_TypeCheck((x), (PyTypeObject *)PyExc_BaseExceptionGroup)73 74/* Predefined exceptions */75 76PyAPI_DATA(PyObject *) PyExc_BaseException;77PyAPI_DATA(PyObject *) PyExc_Exception;78PyAPI_DATA(PyObject *) PyExc_BaseExceptionGroup;79#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0305000080PyAPI_DATA(PyObject *) PyExc_StopAsyncIteration;81#endif82PyAPI_DATA(PyObject *) PyExc_StopIteration;83PyAPI_DATA(PyObject *) PyExc_GeneratorExit;84PyAPI_DATA(PyObject *) PyExc_ArithmeticError;85PyAPI_DATA(PyObject *) PyExc_LookupError;86 87PyAPI_DATA(PyObject *) PyExc_AssertionError;88PyAPI_DATA(PyObject *) PyExc_AttributeError;89PyAPI_DATA(PyObject *) PyExc_BufferError;90PyAPI_DATA(PyObject *) PyExc_EOFError;91PyAPI_DATA(PyObject *) PyExc_FloatingPointError;92PyAPI_DATA(PyObject *) PyExc_OSError;93PyAPI_DATA(PyObject *) PyExc_ImportError;94#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x0306000095PyAPI_DATA(PyObject *) PyExc_ModuleNotFoundError;96#endif97PyAPI_DATA(PyObject *) PyExc_IndexError;98PyAPI_DATA(PyObject *) PyExc_KeyError;99PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;100PyAPI_DATA(PyObject *) PyExc_MemoryError;101PyAPI_DATA(PyObject *) PyExc_NameError;102PyAPI_DATA(PyObject *) PyExc_OverflowError;103PyAPI_DATA(PyObject *) PyExc_RuntimeError;104#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000105PyAPI_DATA(PyObject *) PyExc_RecursionError;106#endif107PyAPI_DATA(PyObject *) PyExc_NotImplementedError;108PyAPI_DATA(PyObject *) PyExc_SyntaxError;109PyAPI_DATA(PyObject *) PyExc_IndentationError;110PyAPI_DATA(PyObject *) PyExc_TabError;111PyAPI_DATA(PyObject *) PyExc_ReferenceError;112PyAPI_DATA(PyObject *) PyExc_SystemError;113PyAPI_DATA(PyObject *) PyExc_SystemExit;114PyAPI_DATA(PyObject *) PyExc_TypeError;115PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;116PyAPI_DATA(PyObject *) PyExc_UnicodeError;117PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;118PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;119PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;120PyAPI_DATA(PyObject *) PyExc_ValueError;121PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;122 123#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000124PyAPI_DATA(PyObject *) PyExc_BlockingIOError;125PyAPI_DATA(PyObject *) PyExc_BrokenPipeError;126PyAPI_DATA(PyObject *) PyExc_ChildProcessError;127PyAPI_DATA(PyObject *) PyExc_ConnectionError;128PyAPI_DATA(PyObject *) PyExc_ConnectionAbortedError;129PyAPI_DATA(PyObject *) PyExc_ConnectionRefusedError;130PyAPI_DATA(PyObject *) PyExc_ConnectionResetError;131PyAPI_DATA(PyObject *) PyExc_FileExistsError;132PyAPI_DATA(PyObject *) PyExc_FileNotFoundError;133PyAPI_DATA(PyObject *) PyExc_InterruptedError;134PyAPI_DATA(PyObject *) PyExc_IsADirectoryError;135PyAPI_DATA(PyObject *) PyExc_NotADirectoryError;136PyAPI_DATA(PyObject *) PyExc_PermissionError;137PyAPI_DATA(PyObject *) PyExc_ProcessLookupError;138PyAPI_DATA(PyObject *) PyExc_TimeoutError;139#endif140 141 142/* Compatibility aliases */143PyAPI_DATA(PyObject *) PyExc_EnvironmentError;144PyAPI_DATA(PyObject *) PyExc_IOError;145#ifdef MS_WINDOWS146PyAPI_DATA(PyObject *) PyExc_WindowsError;147#endif148 149/* Predefined warning categories */150PyAPI_DATA(PyObject *) PyExc_Warning;151PyAPI_DATA(PyObject *) PyExc_UserWarning;152PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;153PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;154PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;155PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;156PyAPI_DATA(PyObject *) PyExc_FutureWarning;157PyAPI_DATA(PyObject *) PyExc_ImportWarning;158PyAPI_DATA(PyObject *) PyExc_UnicodeWarning;159PyAPI_DATA(PyObject *) PyExc_BytesWarning;160PyAPI_DATA(PyObject *) PyExc_EncodingWarning;161PyAPI_DATA(PyObject *) PyExc_ResourceWarning;162 163 164/* Convenience functions */165 166PyAPI_FUNC(int) PyErr_BadArgument(void);167PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);168PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);169PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(170    PyObject *, PyObject *);171#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000172PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObjects(173    PyObject *, PyObject *, PyObject *);174#endif175PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(176    PyObject *exc,177    const char *filename   /* decoded from the filesystem encoding */178    );179 180PyAPI_FUNC(PyObject *) PyErr_Format(181    PyObject *exception,182    const char *format,   /* ASCII-encoded string  */183    ...184    );185#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000186PyAPI_FUNC(PyObject *) PyErr_FormatV(187    PyObject *exception,188    const char *format,189    va_list vargs);190#endif191 192#ifdef MS_WINDOWS193PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(194    int ierr,195    const char *filename        /* decoded from the filesystem encoding */196    );197PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);198PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(199    PyObject *,int, PyObject *);200#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000201PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObjects(202    PyObject *,int, PyObject *, PyObject *);203#endif204PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(205    PyObject *exc,206    int ierr,207    const char *filename        /* decoded from the filesystem encoding */208    );209PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);210#endif /* MS_WINDOWS */211 212#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000213PyAPI_FUNC(PyObject *) PyErr_SetImportErrorSubclass(PyObject *, PyObject *,214    PyObject *, PyObject *);215#endif216#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000217PyAPI_FUNC(PyObject *) PyErr_SetImportError(PyObject *, PyObject *,218    PyObject *);219#endif220 221/* Export the old function so that the existing API remains available: */222PyAPI_FUNC(void) PyErr_BadInternalCall(void);223PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno);224/* Mask the old API with a call to the new API for code compiled under225   Python 2.0: */226#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)227 228/* Function to create a new exception */229PyAPI_FUNC(PyObject *) PyErr_NewException(230    const char *name, PyObject *base, PyObject *dict);231PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(232    const char *name, const char *doc, PyObject *base, PyObject *dict);233PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);234 235 236/* In signalmodule.c */237PyAPI_FUNC(int) PyErr_CheckSignals(void);238PyAPI_FUNC(void) PyErr_SetInterrupt(void);239#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000240PyAPI_FUNC(int) PyErr_SetInterruptEx(int signum);241#endif242 243/* Support for adding program text to SyntaxErrors */244PyAPI_FUNC(void) PyErr_SyntaxLocation(245    const char *filename,       /* decoded from the filesystem encoding */246    int lineno);247PyAPI_FUNC(void) PyErr_SyntaxLocationEx(248    const char *filename,       /* decoded from the filesystem encoding */249    int lineno,250    int col_offset);251PyAPI_FUNC(PyObject *) PyErr_ProgramText(252    const char *filename,       /* decoded from the filesystem encoding */253    int lineno);254 255/* The following functions are used to create and modify unicode256   exceptions from C */257 258/* create a UnicodeDecodeError object */259PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(260    const char *encoding,       /* UTF-8 encoded string */261    const char *object,262    Py_ssize_t length,263    Py_ssize_t start,264    Py_ssize_t end,265    const char *reason          /* UTF-8 encoded string */266    );267 268/* get the encoding attribute */269PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);270PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);271 272/* get the object attribute */273PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);274PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);275PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);276 277/* get the value of the start attribute (the int * may not be NULL)278   return 0 on success, -1 on failure */279PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);280PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);281PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);282 283/* assign a new value to the start attribute284   return 0 on success, -1 on failure */285PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);286PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);287PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);288 289/* get the value of the end attribute (the int *may not be NULL)290 return 0 on success, -1 on failure */291PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);292PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);293PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);294 295/* assign a new value to the end attribute296   return 0 on success, -1 on failure */297PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);298PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);299PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);300 301/* get the value of the reason attribute */302PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *);303PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *);304PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);305 306/* assign a new value to the reason attribute307   return 0 on success, -1 on failure */308PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason(309    PyObject *exc,310    const char *reason          /* UTF-8 encoded string */311    );312PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(313    PyObject *exc,314    const char *reason          /* UTF-8 encoded string */315    );316PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(317    PyObject *exc,318    const char *reason          /* UTF-8 encoded string */319    );320 321PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char  *format, ...)322                        Py_GCC_ATTRIBUTE((format(printf, 3, 4)));323PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char  *format, va_list va)324                        Py_GCC_ATTRIBUTE((format(printf, 3, 0)));325 326#ifndef Py_LIMITED_API327#  define Py_CPYTHON_ERRORS_H328#  include "cpython/pyerrors.h"329#  undef Py_CPYTHON_ERRORS_H330#endif331 332#ifdef __cplusplus333}334#endif335#endif /* !Py_ERRORS_H */336 
codekingpro/portable-devtools · Team Ai