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

Delta Between Two Patch Sets: Include/pyerrors.h

Issue 11682: PEP 380 reference implementation for 3.3
Left Patch Set: Created 7 years, 10 months ago
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 27 matching lines...) Expand all
38 typedef struct { 38 typedef struct {
39 PyException_HEAD 39 PyException_HEAD
40 PyObject *code; 40 PyObject *code;
41 } PySystemExitObject; 41 } PySystemExitObject;
42 42
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 } PyEnvironmentErrorObject; 48 #ifdef MS_WINDOWS
49 PyObject *winerror;
50 #endif
51 Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */
52 } PyOSErrorObject;
49 53
50 typedef struct { 54 typedef struct {
51 PyException_HEAD 55 PyException_HEAD
52 PyObject *value; 56 PyObject *value;
53 } PyStopIterationObject; 57 } PyStopIterationObject;
54 58
59 /* Compatibility typedefs */
60 typedef PyOSErrorObject PyEnvironmentErrorObject;
55 #ifdef MS_WINDOWS 61 #ifdef MS_WINDOWS
56 typedef struct { 62 typedef PyOSErrorObject PyWindowsErrorObject;
57 PyException_HEAD 63 #endif
58 PyObject *myerrno; 64 #endif /* !Py_LIMITED_API */
59 PyObject *strerror;
60 PyObject *filename;
61 PyObject *winerror;
62 } PyWindowsErrorObject;
63 #endif
64 #endif
65 65
66 /* Error handling definitions */ 66 /* Error handling definitions */
67 67
68 PyAPI_FUNC(void) PyErr_SetNone(PyObject *); 68 PyAPI_FUNC(void) PyErr_SetNone(PyObject *);
69 PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *); 69 PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);
70 PyAPI_FUNC(void) PyErr_SetString( 70 PyAPI_FUNC(void) PyErr_SetString(
71 PyObject *exception, 71 PyObject *exception,
72 const char *string /* decoded from utf-8 */ 72 const char *string /* decoded from utf-8 */
73 ); 73 );
74 PyAPI_FUNC(PyObject *) PyErr_Occurred(void); 74 PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 PyAPI_DATA(PyObject *) PyExc_BaseException; 131 PyAPI_DATA(PyObject *) PyExc_BaseException;
132 PyAPI_DATA(PyObject *) PyExc_Exception; 132 PyAPI_DATA(PyObject *) PyExc_Exception;
133 PyAPI_DATA(PyObject *) PyExc_StopIteration; 133 PyAPI_DATA(PyObject *) PyExc_StopIteration;
134 PyAPI_DATA(PyObject *) PyExc_GeneratorExit; 134 PyAPI_DATA(PyObject *) PyExc_GeneratorExit;
135 PyAPI_DATA(PyObject *) PyExc_ArithmeticError; 135 PyAPI_DATA(PyObject *) PyExc_ArithmeticError;
136 PyAPI_DATA(PyObject *) PyExc_LookupError; 136 PyAPI_DATA(PyObject *) PyExc_LookupError;
137 137
138 PyAPI_DATA(PyObject *) PyExc_AssertionError; 138 PyAPI_DATA(PyObject *) PyExc_AssertionError;
139 PyAPI_DATA(PyObject *) PyExc_AttributeError; 139 PyAPI_DATA(PyObject *) PyExc_AttributeError;
140 PyAPI_DATA(PyObject *) PyExc_BufferError;
140 PyAPI_DATA(PyObject *) PyExc_EOFError; 141 PyAPI_DATA(PyObject *) PyExc_EOFError;
141 PyAPI_DATA(PyObject *) PyExc_FloatingPointError; 142 PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
142 PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
143 PyAPI_DATA(PyObject *) PyExc_IOError;
144 PyAPI_DATA(PyObject *) PyExc_OSError; 143 PyAPI_DATA(PyObject *) PyExc_OSError;
145 PyAPI_DATA(PyObject *) PyExc_ImportError; 144 PyAPI_DATA(PyObject *) PyExc_ImportError;
146 PyAPI_DATA(PyObject *) PyExc_IndexError; 145 PyAPI_DATA(PyObject *) PyExc_IndexError;
147 PyAPI_DATA(PyObject *) PyExc_KeyError; 146 PyAPI_DATA(PyObject *) PyExc_KeyError;
148 PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt; 147 PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;
149 PyAPI_DATA(PyObject *) PyExc_MemoryError; 148 PyAPI_DATA(PyObject *) PyExc_MemoryError;
150 PyAPI_DATA(PyObject *) PyExc_NameError; 149 PyAPI_DATA(PyObject *) PyExc_NameError;
151 PyAPI_DATA(PyObject *) PyExc_OverflowError; 150 PyAPI_DATA(PyObject *) PyExc_OverflowError;
152 PyAPI_DATA(PyObject *) PyExc_RuntimeError; 151 PyAPI_DATA(PyObject *) PyExc_RuntimeError;
153 PyAPI_DATA(PyObject *) PyExc_NotImplementedError; 152 PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
154 PyAPI_DATA(PyObject *) PyExc_SyntaxError; 153 PyAPI_DATA(PyObject *) PyExc_SyntaxError;
155 PyAPI_DATA(PyObject *) PyExc_IndentationError; 154 PyAPI_DATA(PyObject *) PyExc_IndentationError;
156 PyAPI_DATA(PyObject *) PyExc_TabError; 155 PyAPI_DATA(PyObject *) PyExc_TabError;
157 PyAPI_DATA(PyObject *) PyExc_ReferenceError; 156 PyAPI_DATA(PyObject *) PyExc_ReferenceError;
158 PyAPI_DATA(PyObject *) PyExc_SystemError; 157 PyAPI_DATA(PyObject *) PyExc_SystemError;
159 PyAPI_DATA(PyObject *) PyExc_SystemExit; 158 PyAPI_DATA(PyObject *) PyExc_SystemExit;
160 PyAPI_DATA(PyObject *) PyExc_TypeError; 159 PyAPI_DATA(PyObject *) PyExc_TypeError;
161 PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; 160 PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
162 PyAPI_DATA(PyObject *) PyExc_UnicodeError; 161 PyAPI_DATA(PyObject *) PyExc_UnicodeError;
163 PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; 162 PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
164 PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError; 163 PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
165 PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError; 164 PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
166 PyAPI_DATA(PyObject *) PyExc_ValueError; 165 PyAPI_DATA(PyObject *) PyExc_ValueError;
167 PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError; 166 PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
167
168 PyAPI_DATA(PyObject *) PyExc_BlockingIOError;
169 PyAPI_DATA(PyObject *) PyExc_BrokenPipeError;
170 PyAPI_DATA(PyObject *) PyExc_ChildProcessError;
171 PyAPI_DATA(PyObject *) PyExc_ConnectionError;
172 PyAPI_DATA(PyObject *) PyExc_ConnectionAbortedError;
173 PyAPI_DATA(PyObject *) PyExc_ConnectionRefusedError;
174 PyAPI_DATA(PyObject *) PyExc_ConnectionResetError;
175 PyAPI_DATA(PyObject *) PyExc_FileExistsError;
176 PyAPI_DATA(PyObject *) PyExc_FileNotFoundError;
177 PyAPI_DATA(PyObject *) PyExc_InterruptedError;
178 PyAPI_DATA(PyObject *) PyExc_IsADirectoryError;
179 PyAPI_DATA(PyObject *) PyExc_NotADirectoryError;
180 PyAPI_DATA(PyObject *) PyExc_PermissionError;
181 PyAPI_DATA(PyObject *) PyExc_ProcessLookupError;
182 PyAPI_DATA(PyObject *) PyExc_TimeoutError;
183
184
185 /* Compatibility aliases */
186 PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
187 PyAPI_DATA(PyObject *) PyExc_IOError;
168 #ifdef MS_WINDOWS 188 #ifdef MS_WINDOWS
169 PyAPI_DATA(PyObject *) PyExc_WindowsError; 189 PyAPI_DATA(PyObject *) PyExc_WindowsError;
170 #endif 190 #endif
171 #ifdef __VMS 191 #ifdef __VMS
172 PyAPI_DATA(PyObject *) PyExc_VMSError; 192 PyAPI_DATA(PyObject *) PyExc_VMSError;
173 #endif 193 #endif
174
175 PyAPI_DATA(PyObject *) PyExc_BufferError;
176 194
177 PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst; 195 PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst;
178 196
179 /* Predefined warning categories */ 197 /* Predefined warning categories */
180 PyAPI_DATA(PyObject *) PyExc_Warning; 198 PyAPI_DATA(PyObject *) PyExc_Warning;
181 PyAPI_DATA(PyObject *) PyExc_UserWarning; 199 PyAPI_DATA(PyObject *) PyExc_UserWarning;
182 PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; 200 PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;
183 PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; 201 PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
184 PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; 202 PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;
185 PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; 203 PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 317
300 /* create a UnicodeTranslateError object */ 318 /* create a UnicodeTranslateError object */
301 #ifndef Py_LIMITED_API 319 #ifndef Py_LIMITED_API
302 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( 320 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
303 const Py_UNICODE *object, 321 const Py_UNICODE *object,
304 Py_ssize_t length, 322 Py_ssize_t length,
305 Py_ssize_t start, 323 Py_ssize_t start,
306 Py_ssize_t end, 324 Py_ssize_t end,
307 const char *reason /* UTF-8 encoded string */ 325 const char *reason /* UTF-8 encoded string */
308 ); 326 );
327 PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
328 PyObject *object,
329 Py_ssize_t start,
330 Py_ssize_t end,
331 const char *reason /* UTF-8 encoded string */
332 );
309 #endif 333 #endif
310 334
311 /* get the encoding attribute */ 335 /* get the encoding attribute */
312 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); 336 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
313 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *); 337 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);
314 338
315 /* get the object attribute */ 339 /* get the object attribute */
316 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *); 340 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);
317 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *); 341 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);
318 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *); 342 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( 379 PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
356 PyObject *exc, 380 PyObject *exc,
357 const char *reason /* UTF-8 encoded string */ 381 const char *reason /* UTF-8 encoded string */
358 ); 382 );
359 PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( 383 PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
360 PyObject *exc, 384 PyObject *exc,
361 const char *reason /* UTF-8 encoded string */ 385 const char *reason /* UTF-8 encoded string */
362 ); 386 );
363 387
364 /* create a StopIteration exception with the given value */ 388 /* create a StopIteration exception with the given value */
365 PyAPI_FUNC(PyObject *) PyStopIteration_New(PyObject *); 389 PyAPI_FUNC(PyObject *) PyStopIteration_Create(PyObject *);
Benjamin Peterson 2011/07/09 18:41:14 PyStopIteraiton_Create would be more consistent wi
Nick Coghlan 2011/09/20 13:24:23 Done.
366 390
367 /* These APIs aren't really part of the error implementation, but 391 /* These APIs aren't really part of the error implementation, but
368 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
369 not available on all platforms, which is why we provide emulations 393 not available on all platforms, which is why we provide emulations
370 for those platforms in Python/mysnprintf.c, 394 for those platforms in Python/mysnprintf.c,
371 WARNING: The return value of snprintf varies across platforms; do 395 WARNING: The return value of snprintf varies across platforms; do
372 not rely on any particular behavior; eventually the C99 defn may 396 not rely on any particular behavior; eventually the C99 defn may
373 be reliable. 397 be reliable.
374 */ 398 */
375 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF) 399 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
376 # define HAVE_SNPRINTF 400 # define HAVE_SNPRINTF
377 # define snprintf _snprintf 401 # define snprintf _snprintf
378 # define vsnprintf _vsnprintf 402 # define vsnprintf _vsnprintf
379 #endif 403 #endif
380 404
381 #include <stdarg.h> 405 #include <stdarg.h>
382 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, ...)
383 Py_GCC_ATTRIBUTE((format(printf, 3, 4))); 407 Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
384 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)
385 Py_GCC_ATTRIBUTE((format(printf, 3, 0))); 409 Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
386 410
387 #ifdef __cplusplus 411 #ifdef __cplusplus
388 } 412 }
389 #endif 413 #endif
390 #endif /* !Py_ERRORS_H */ 414 #endif /* !Py_ERRORS_H */
LEFTRIGHT

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