File: /Users/paulross/dev/Python-3.6.2/Include/pyerrors.h

Green shading in the line number column means the source is part of the translation unit, red means it is conditionally excluded. Highlighted line numbers link to the translation unit page. Highlighted macros link to the macro page.

       1: #ifndef Py_ERRORS_H
       2: #define Py_ERRORS_H
       3: #ifdef __cplusplus
       4: extern "C" {
       5: #endif
       6: 
       7: /* Error objects */
       8: 
       9: #ifndef Py_LIMITED_API
      10: /* PyException_HEAD defines the initial segment of every exception class. */
      11: #define PyException_HEAD PyObject_HEAD PyObject *dict;\
             PyObject *args; PyObject *traceback;\
             PyObject *context; PyObject *cause;\
             char suppress_context;
      15: 
      16: typedef struct {
      17:     PyException_HEAD
      18: } PyBaseExceptionObject;
      19: 
      20: typedef struct {
      21:     PyException_HEAD
      22:     PyObject *msg;
      23:     PyObject *filename;
      24:     PyObject *lineno;
      25:     PyObject *offset;
      26:     PyObject *text;
      27:     PyObject *print_file_and_line;
      28: } PySyntaxErrorObject;
      29: 
      30: typedef struct {
      31:     PyException_HEAD
      32:     PyObject *msg;
      33:     PyObject *name;
      34:     PyObject *path;
      35: } PyImportErrorObject;
      36: 
      37: typedef struct {
      38:     PyException_HEAD
      39:     PyObject *encoding;
      40:     PyObject *object;
      41:     Py_ssize_t start;
      42:     Py_ssize_t end;
      43:     PyObject *reason;
      44: } PyUnicodeErrorObject;
      45: 
      46: typedef struct {
      47:     PyException_HEAD
      48:     PyObject *code;
      49: } PySystemExitObject;
      50: 
      51: typedef struct {
      52:     PyException_HEAD
      53:     PyObject *myerrno;
      54:     PyObject *strerror;
      55:     PyObject *filename;
      56:     PyObject *filename2;
      57: #ifdef MS_WINDOWS
      58:     PyObject *winerror;
      59: #endif
      60:     Py_ssize_t written;   /* only for BlockingIOError, -1 otherwise */
      61: } PyOSErrorObject;
      62: 
      63: typedef struct {
      64:     PyException_HEAD
      65:     PyObject *value;
      66: } PyStopIterationObject;
      67: 
      68: /* Compatibility typedefs */
      69: typedef PyOSErrorObject PyEnvironmentErrorObject;
      70: #ifdef MS_WINDOWS
      71: typedef PyOSErrorObject PyWindowsErrorObject;
      72: #endif
      73: #endif /* !Py_LIMITED_API */
      74: 
      75: /* Error handling definitions */
      76: 
      77: PyAPI_FUNC(void) PyErr_SetNone(PyObject *);
      78: PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);
      79: #ifndef Py_LIMITED_API
      80: PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *);
      81: #endif
      82: PyAPI_FUNC(void) PyErr_SetString(
      83:     PyObject *exception,
      84:     const char *string   /* decoded from utf-8 */
      85:     );
      86: PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
      87: PyAPI_FUNC(void) PyErr_Clear(void);
      88: PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
      89: PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
      90: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
      91: PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **);
      92: PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
      93: #endif
      94: 
      95: #if defined(__clang__) || \
      96:     (defined(__GNUC_MAJOR__) && \
      97:      ((__GNUC_MAJOR__ >= 3) || \
      98:       (__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5)))
      99: #define _Py_NO_RETURN __attribute__((__noreturn__))
     100: #else
     101: #define _Py_NO_RETURN
     102: #endif
     103: 
     104: /* Defined in Python/pylifecycle.c */
     105: PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN;
     106: 
     107: #if defined(Py_DEBUG) || defined(Py_LIMITED_API)
     108: #define _PyErr_OCCURRED() PyErr_Occurred()
     109: #else
     110: #define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type)
     111: #endif
     112: 
     113: /* Error testing and normalization */
     114: PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
     115: PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *);
     116: PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
     117: 
     118: /* Traceback manipulation (PEP 3134) */
     119: PyAPI_FUNC(int) PyException_SetTraceback(PyObject *, PyObject *);
     120: PyAPI_FUNC(PyObject *) PyException_GetTraceback(PyObject *);
     121: 
     122: /* Cause manipulation (PEP 3134) */
     123: PyAPI_FUNC(PyObject *) PyException_GetCause(PyObject *);
     124: PyAPI_FUNC(void) PyException_SetCause(PyObject *, PyObject *);
     125: 
     126: /* Context manipulation (PEP 3134) */
     127: PyAPI_FUNC(PyObject *) PyException_GetContext(PyObject *);
     128: PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);
     129: #ifndef Py_LIMITED_API
     130: PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
     131: #endif
     132: 
     133: /* */
     134: 
     135: #define PyExceptionClass_Check(x)                                       \
     136:     (PyType_Check((x)) &&                                               \
     137:      PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))
     138: 
     139: #define PyExceptionInstance_Check(x)                    \
     140:     PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)
     141: 
     142: #define PyExceptionClass_Name(x) \
     143:      ((char *)(((PyTypeObject*)(x))->tp_name))
     144: 
     145: #define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type))
     146: 
     147: 
     148: /* Predefined exceptions */
     149: 
     150: PyAPI_DATA(PyObject *) PyExc_BaseException;
     151: PyAPI_DATA(PyObject *) PyExc_Exception;
     152: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
     153: PyAPI_DATA(PyObject *) PyExc_StopAsyncIteration;
     154: #endif
     155: PyAPI_DATA(PyObject *) PyExc_StopIteration;
     156: PyAPI_DATA(PyObject *) PyExc_GeneratorExit;
     157: PyAPI_DATA(PyObject *) PyExc_ArithmeticError;
     158: PyAPI_DATA(PyObject *) PyExc_LookupError;
     159: 
     160: PyAPI_DATA(PyObject *) PyExc_AssertionError;
     161: PyAPI_DATA(PyObject *) PyExc_AttributeError;
     162: PyAPI_DATA(PyObject *) PyExc_BufferError;
     163: PyAPI_DATA(PyObject *) PyExc_EOFError;
     164: PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
     165: PyAPI_DATA(PyObject *) PyExc_OSError;
     166: PyAPI_DATA(PyObject *) PyExc_ImportError;
     167: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
     168: PyAPI_DATA(PyObject *) PyExc_ModuleNotFoundError;
     169: #endif
     170: PyAPI_DATA(PyObject *) PyExc_IndexError;
     171: PyAPI_DATA(PyObject *) PyExc_KeyError;
     172: PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;
     173: PyAPI_DATA(PyObject *) PyExc_MemoryError;
     174: PyAPI_DATA(PyObject *) PyExc_NameError;
     175: PyAPI_DATA(PyObject *) PyExc_OverflowError;
     176: PyAPI_DATA(PyObject *) PyExc_RuntimeError;
     177: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
     178: PyAPI_DATA(PyObject *) PyExc_RecursionError;
     179: #endif
     180: PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
     181: PyAPI_DATA(PyObject *) PyExc_SyntaxError;
     182: PyAPI_DATA(PyObject *) PyExc_IndentationError;
     183: PyAPI_DATA(PyObject *) PyExc_TabError;
     184: PyAPI_DATA(PyObject *) PyExc_ReferenceError;
     185: PyAPI_DATA(PyObject *) PyExc_SystemError;
     186: PyAPI_DATA(PyObject *) PyExc_SystemExit;
     187: PyAPI_DATA(PyObject *) PyExc_TypeError;
     188: PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
     189: PyAPI_DATA(PyObject *) PyExc_UnicodeError;
     190: PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
     191: PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
     192: PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
     193: PyAPI_DATA(PyObject *) PyExc_ValueError;
     194: PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
     195: 
     196: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
     197: PyAPI_DATA(PyObject *) PyExc_BlockingIOError;
     198: PyAPI_DATA(PyObject *) PyExc_BrokenPipeError;
     199: PyAPI_DATA(PyObject *) PyExc_ChildProcessError;
     200: PyAPI_DATA(PyObject *) PyExc_ConnectionError;
     201: PyAPI_DATA(PyObject *) PyExc_ConnectionAbortedError;
     202: PyAPI_DATA(PyObject *) PyExc_ConnectionRefusedError;
     203: PyAPI_DATA(PyObject *) PyExc_ConnectionResetError;
     204: PyAPI_DATA(PyObject *) PyExc_FileExistsError;
     205: PyAPI_DATA(PyObject *) PyExc_FileNotFoundError;
     206: PyAPI_DATA(PyObject *) PyExc_InterruptedError;
     207: PyAPI_DATA(PyObject *) PyExc_IsADirectoryError;
     208: PyAPI_DATA(PyObject *) PyExc_NotADirectoryError;
     209: PyAPI_DATA(PyObject *) PyExc_PermissionError;
     210: PyAPI_DATA(PyObject *) PyExc_ProcessLookupError;
     211: PyAPI_DATA(PyObject *) PyExc_TimeoutError;
     212: #endif
     213: 
     214: 
     215: /* Compatibility aliases */
     216: PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
     217: PyAPI_DATA(PyObject *) PyExc_IOError;
     218: #ifdef MS_WINDOWS
     219: PyAPI_DATA(PyObject *) PyExc_WindowsError;
     220: #endif
     221: 
     222: PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst;
     223: 
     224: /* Predefined warning categories */
     225: PyAPI_DATA(PyObject *) PyExc_Warning;
     226: PyAPI_DATA(PyObject *) PyExc_UserWarning;
     227: PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;
     228: PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
     229: PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;
     230: PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;
     231: PyAPI_DATA(PyObject *) PyExc_FutureWarning;
     232: PyAPI_DATA(PyObject *) PyExc_ImportWarning;
     233: PyAPI_DATA(PyObject *) PyExc_UnicodeWarning;
     234: PyAPI_DATA(PyObject *) PyExc_BytesWarning;
     235: PyAPI_DATA(PyObject *) PyExc_ResourceWarning;
     236: 
     237: 
     238: /* Convenience functions */
     239: 
     240: PyAPI_FUNC(int) PyErr_BadArgument(void);
     241: PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);
     242: PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);
     243: PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(
     244:     PyObject *, PyObject *);
     245: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
     246: PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObjects(
     247:     PyObject *, PyObject *, PyObject *);
     248: #endif
     249: PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
     250:     PyObject *exc,
     251:     const char *filename   /* decoded from the filesystem encoding */
     252:     );
     253: #if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
     254: PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
     255:     PyObject *, const Py_UNICODE *);
     256: #endif /* MS_WINDOWS */
     257: 
     258: PyAPI_FUNC(PyObject *) PyErr_Format(
     259:     PyObject *exception,
     260:     const char *format,   /* ASCII-encoded string  */
     261:     ...
     262:     );
     263: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
     264: PyAPI_FUNC(PyObject *) PyErr_FormatV(
     265:     PyObject *exception,
     266:     const char *format,
     267:     va_list vargs);
     268: #endif
     269: 
     270: #ifndef Py_LIMITED_API
     271: /* Like PyErr_Format(), but saves current exception as __context__ and
     272:    __cause__.
     273:  */
     274: PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
     275:     PyObject *exception,
     276:     const char *format,   /* ASCII-encoded string  */
     277:     ...
     278:     );
     279: #endif
     280: 
     281: #ifdef MS_WINDOWS
     282: PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
     283:     int ierr,
     284:     const char *filename        /* decoded from the filesystem encoding */
     285:     );
     286: #ifndef Py_LIMITED_API
     287: /* XXX redeclare to use WSTRING */
     288: PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
     289:     int, const Py_UNICODE *);
     290: #endif
     291: PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
     292: PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
     293:     PyObject *,int, PyObject *);
     294: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
     295: PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObjects(
     296:     PyObject *,int, PyObject *, PyObject *);
     297: #endif
     298: PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
     299:     PyObject *exc,
     300:     int ierr,
     301:     const char *filename        /* decoded from the filesystem encoding */
     302:     );
     303: #ifndef Py_LIMITED_API
     304: PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
     305:     PyObject *,int, const Py_UNICODE *);
     306: #endif
     307: PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
     308: #endif /* MS_WINDOWS */
     309: 
     310: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
     311: PyAPI_FUNC(PyObject *) PyErr_SetImportErrorSubclass(PyObject *, PyObject *,
     312:     PyObject *, PyObject *);
     313: #endif
     314: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
     315: PyAPI_FUNC(PyObject *) PyErr_SetImportError(PyObject *, PyObject *,
     316:     PyObject *);
     317: #endif
     318: 
     319: /* Export the old function so that the existing API remains available: */
     320: PyAPI_FUNC(void) PyErr_BadInternalCall(void);
     321: PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno);
     322: /* Mask the old API with a call to the new API for code compiled under
     323:    Python 2.0: */
     324: #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
     325: 
     326: /* Function to create a new exception */
     327: PyAPI_FUNC(PyObject *) PyErr_NewException(
     328:     const char *name, PyObject *base, PyObject *dict);
     329: PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(
     330:     const char *name, const char *doc, PyObject *base, PyObject *dict);
     331: PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
     332: 
     333: /* In exceptions.c */
     334: #ifndef Py_LIMITED_API
     335: /* Helper that attempts to replace the current exception with one of the
     336:  * same type but with a prefix added to the exception text. The resulting
     337:  * exception description looks like:
     338:  *
     339:  *     prefix (exc_type: original_exc_str)
     340:  *
     341:  * Only some exceptions can be safely replaced. If the function determines
     342:  * it isn't safe to perform the replacement, it will leave the original
     343:  * unmodified exception in place.
     344:  *
     345:  * Returns a borrowed reference to the new exception (if any), NULL if the
     346:  * existing exception was left in place.
     347:  */
     348: PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
     349:     const char *prefix_format,   /* ASCII-encoded string  */
     350:     ...
     351:     );
     352: #endif
     353: 
     354: 
     355: /* In sigcheck.c or signalmodule.c */
     356: PyAPI_FUNC(int) PyErr_CheckSignals(void);
     357: PyAPI_FUNC(void) PyErr_SetInterrupt(void);
     358: 
     359: /* In signalmodule.c */
     360: #ifndef Py_LIMITED_API
     361: int PySignal_SetWakeupFd(int fd);
     362: #endif
     363: 
     364: /* Support for adding program text to SyntaxErrors */
     365: PyAPI_FUNC(void) PyErr_SyntaxLocation(
     366:     const char *filename,       /* decoded from the filesystem encoding */
     367:     int lineno);
     368: PyAPI_FUNC(void) PyErr_SyntaxLocationEx(
     369:     const char *filename,       /* decoded from the filesystem encoding */
     370:     int lineno,
     371:     int col_offset);
     372: #ifndef Py_LIMITED_API
     373: PyAPI_FUNC(void) PyErr_SyntaxLocationObject(
     374:     PyObject *filename,
     375:     int lineno,
     376:     int col_offset);
     377: #endif
     378: PyAPI_FUNC(PyObject *) PyErr_ProgramText(
     379:     const char *filename,       /* decoded from the filesystem encoding */
     380:     int lineno);
     381: #ifndef Py_LIMITED_API
     382: PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
     383:     PyObject *filename,
     384:     int lineno);
     385: #endif
     386: 
     387: /* The following functions are used to create and modify unicode
     388:    exceptions from C */
     389: 
     390: /* create a UnicodeDecodeError object */
     391: PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
     392:     const char *encoding,       /* UTF-8 encoded string */
     393:     const char *object,
     394:     Py_ssize_t length,
     395:     Py_ssize_t start,
     396:     Py_ssize_t end,
     397:     const char *reason          /* UTF-8 encoded string */
     398:     );
     399: 
     400: /* create a UnicodeEncodeError object */
     401: #ifndef Py_LIMITED_API
     402: PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
     403:     const char *encoding,       /* UTF-8 encoded string */
     404:     const Py_UNICODE *object,
     405:     Py_ssize_t length,
     406:     Py_ssize_t start,
     407:     Py_ssize_t end,
     408:     const char *reason          /* UTF-8 encoded string */
     409:     );
     410: #endif
     411: 
     412: /* create a UnicodeTranslateError object */
     413: #ifndef Py_LIMITED_API
     414: PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
     415:     const Py_UNICODE *object,
     416:     Py_ssize_t length,
     417:     Py_ssize_t start,
     418:     Py_ssize_t end,
     419:     const char *reason          /* UTF-8 encoded string */
     420:     );
     421: PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
     422:     PyObject *object,
     423:     Py_ssize_t start,
     424:     Py_ssize_t end,
     425:     const char *reason          /* UTF-8 encoded string */
     426:     );
     427: #endif
     428: 
     429: /* get the encoding attribute */
     430: PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
     431: PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);
     432: 
     433: /* get the object attribute */
     434: PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);
     435: PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);
     436: PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
     437: 
     438: /* get the value of the start attribute (the int * may not be NULL)
     439:    return 0 on success, -1 on failure */
     440: PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);
     441: PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);
     442: PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);
     443: 
     444: /* assign a new value to the start attribute
     445:    return 0 on success, -1 on failure */
     446: PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);
     447: PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);
     448: PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);
     449: 
     450: /* get the value of the end attribute (the int *may not be NULL)
     451:  return 0 on success, -1 on failure */
     452: PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);
     453: PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);
     454: PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);
     455: 
     456: /* assign a new value to the end attribute
     457:    return 0 on success, -1 on failure */
     458: PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);
     459: PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);
     460: PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);
     461: 
     462: /* get the value of the reason attribute */
     463: PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *);
     464: PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *);
     465: PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
     466: 
     467: /* assign a new value to the reason attribute
     468:    return 0 on success, -1 on failure */
     469: PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason(
     470:     PyObject *exc,
     471:     const char *reason          /* UTF-8 encoded string */
     472:     );
     473: PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
     474:     PyObject *exc,
     475:     const char *reason          /* UTF-8 encoded string */
     476:     );
     477: PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
     478:     PyObject *exc,
     479:     const char *reason          /* UTF-8 encoded string */
     480:     );
     481: 
     482: /* These APIs aren't really part of the error implementation, but
     483:    often needed to format error messages; the native C lib APIs are
     484:    not available on all platforms, which is why we provide emulations
     485:    for those platforms in Python/mysnprintf.c,
     486:    WARNING:  The return value of snprintf varies across platforms; do
     487:    not rely on any particular behavior; eventually the C99 defn may
     488:    be reliable.
     489: */
     490: #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
     491: # define HAVE_SNPRINTF
     492: # define snprintf _snprintf
     493: # define vsnprintf _vsnprintf
     494: #endif
     495: 
     496: #include <stdarg.h>
     497: PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char  *format, ...)
     498:                         Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
     499: PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char  *format, va_list va)
     500:                         Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
     501: 
     502: #ifdef __cplusplus
     503: }
     504: #endif
     505: #endif /* !Py_ERRORS_H */
     506: