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