Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2652)

Side by Side Diff: Include/pyerrors.h

Issue 11682: PEP 380 reference implementation for 3.3
Patch Set: Created 7 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #ifndef Py_ERRORS_H 1 #ifndef Py_ERRORS_H
2 #define Py_ERRORS_H 2 #define Py_ERRORS_H
3 #ifdef __cplusplus 3 #ifdef __cplusplus
4 extern "C" { 4 extern "C" {
5 #endif 5 #endif
6 6
7 /* Error objects */ 7 /* Error objects */
8 8
9 #ifndef Py_LIMITED_API 9 #ifndef Py_LIMITED_API
10 /* PyException_HEAD defines the initial segment of every exception class. */ 10 /* PyException_HEAD defines the initial segment of every exception class. */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 typedef struct { 43 typedef struct {
44 PyException_HEAD 44 PyException_HEAD
45 PyObject *myerrno; 45 PyObject *myerrno;
46 PyObject *strerror; 46 PyObject *strerror;
47 PyObject *filename; 47 PyObject *filename;
48 #ifdef MS_WINDOWS 48 #ifdef MS_WINDOWS
49 PyObject *winerror; 49 PyObject *winerror;
50 #endif 50 #endif
51 Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */ 51 Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */
52 } PyOSErrorObject; 52 } PyOSErrorObject;
53
54 typedef struct {
55 PyException_HEAD
56 PyObject *value;
57 } PyStopIterationObject;
53 58
54 /* Compatibility typedefs */ 59 /* Compatibility typedefs */
55 typedef PyOSErrorObject PyEnvironmentErrorObject; 60 typedef PyOSErrorObject PyEnvironmentErrorObject;
56 #ifdef MS_WINDOWS 61 #ifdef MS_WINDOWS
57 typedef PyOSErrorObject PyWindowsErrorObject; 62 typedef PyOSErrorObject PyWindowsErrorObject;
58 #endif 63 #endif
59 #endif /* !Py_LIMITED_API */ 64 #endif /* !Py_LIMITED_API */
60 65
61 /* Error handling definitions */ 66 /* Error handling definitions */
62 67
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 ); 378 );
374 PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( 379 PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
375 PyObject *exc, 380 PyObject *exc,
376 const char *reason /* UTF-8 encoded string */ 381 const char *reason /* UTF-8 encoded string */
377 ); 382 );
378 PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( 383 PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
379 PyObject *exc, 384 PyObject *exc,
380 const char *reason /* UTF-8 encoded string */ 385 const char *reason /* UTF-8 encoded string */
381 ); 386 );
382 387
388 /* create a StopIteration exception with the given value */
389 PyAPI_FUNC(PyObject *) PyStopIteration_Create(PyObject *);
383 390
384 /* These APIs aren't really part of the error implementation, but 391 /* These APIs aren't really part of the error implementation, but
385 often needed to format error messages; the native C lib APIs are 392 often needed to format error messages; the native C lib APIs are
386 not available on all platforms, which is why we provide emulations 393 not available on all platforms, which is why we provide emulations
387 for those platforms in Python/mysnprintf.c, 394 for those platforms in Python/mysnprintf.c,
388 WARNING: The return value of snprintf varies across platforms; do 395 WARNING: The return value of snprintf varies across platforms; do
389 not rely on any particular behavior; eventually the C99 defn may 396 not rely on any particular behavior; eventually the C99 defn may
390 be reliable. 397 be reliable.
391 */ 398 */
392 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF) 399 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
393 # define HAVE_SNPRINTF 400 # define HAVE_SNPRINTF
394 # define snprintf _snprintf 401 # define snprintf _snprintf
395 # define vsnprintf _vsnprintf 402 # define vsnprintf _vsnprintf
396 #endif 403 #endif
397 404
398 #include <stdarg.h> 405 #include <stdarg.h>
399 PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) 406 PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...)
400 Py_GCC_ATTRIBUTE((format(printf, 3, 4))); 407 Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
401 PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_l ist va) 408 PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_l ist va)
402 Py_GCC_ATTRIBUTE((format(printf, 3, 0))); 409 Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
403 410
404 #ifdef __cplusplus 411 #ifdef __cplusplus
405 } 412 }
406 #endif 413 #endif
407 #endif /* !Py_ERRORS_H */ 414 #endif /* !Py_ERRORS_H */
OLDNEW
« no previous file with comments | « Include/opcode.h ('k') | Include/Python-ast.h » ('j') | Modules/parsermodule.c » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+