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

Delta Between Two Patch Sets: Include/pyerrors.h

Issue 11619: On Windows, don't encode filenames in the import machinery
Left Patch Set: Created 8 years, 4 months ago
Right Patch Set: Created 5 years, 11 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
« no previous file with change/comment | « Include/parsetok.h ('k') | Include/pythonrun.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. */
11 #define PyException_HEAD PyObject_HEAD PyObject *dict;\ 11 #define PyException_HEAD PyObject_HEAD PyObject *dict;\
12 PyObject *args; PyObject *traceback;\ 12 PyObject *args; PyObject *traceback;\
13 PyObject *context; PyObject *cause; 13 PyObject *context; PyObject *cause;\
14 char suppress_context;
14 15
15 typedef struct { 16 typedef struct {
16 PyException_HEAD 17 PyException_HEAD
17 } PyBaseExceptionObject; 18 } PyBaseExceptionObject;
18 19
19 typedef struct { 20 typedef struct {
20 PyException_HEAD 21 PyException_HEAD
21 PyObject *msg; 22 PyObject *msg;
22 PyObject *filename; 23 PyObject *filename;
23 PyObject *lineno; 24 PyObject *lineno;
24 PyObject *offset; 25 PyObject *offset;
25 PyObject *text; 26 PyObject *text;
26 PyObject *print_file_and_line; 27 PyObject *print_file_and_line;
27 } PySyntaxErrorObject; 28 } PySyntaxErrorObject;
28 29
29 typedef struct { 30 typedef struct {
30 PyException_HEAD 31 PyException_HEAD
32 PyObject *msg;
33 PyObject *name;
34 PyObject *path;
35 } PyImportErrorObject;
36
37 typedef struct {
38 PyException_HEAD
31 PyObject *encoding; 39 PyObject *encoding;
32 PyObject *object; 40 PyObject *object;
33 Py_ssize_t start; 41 Py_ssize_t start;
34 Py_ssize_t end; 42 Py_ssize_t end;
35 PyObject *reason; 43 PyObject *reason;
36 } PyUnicodeErrorObject; 44 } PyUnicodeErrorObject;
37 45
38 typedef struct { 46 typedef struct {
39 PyException_HEAD 47 PyException_HEAD
40 PyObject *code; 48 PyObject *code;
41 } PySystemExitObject; 49 } PySystemExitObject;
42 50
43 typedef struct { 51 typedef struct {
44 PyException_HEAD 52 PyException_HEAD
45 PyObject *myerrno; 53 PyObject *myerrno;
46 PyObject *strerror; 54 PyObject *strerror;
47 PyObject *filename; 55 PyObject *filename;
48 } PyEnvironmentErrorObject;
49
50 #ifdef MS_WINDOWS 56 #ifdef MS_WINDOWS
51 typedef struct {
52 PyException_HEAD
53 PyObject *myerrno;
54 PyObject *strerror;
55 PyObject *filename;
56 PyObject *winerror; 57 PyObject *winerror;
57 } PyWindowsErrorObject; 58 #endif
58 #endif 59 Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */
59 #endif 60 } PyOSErrorObject;
61
62 typedef struct {
63 PyException_HEAD
64 PyObject *value;
65 } PyStopIterationObject;
66
67 /* Compatibility typedefs */
68 typedef PyOSErrorObject PyEnvironmentErrorObject;
69 #ifdef MS_WINDOWS
70 typedef PyOSErrorObject PyWindowsErrorObject;
71 #endif
72 #endif /* !Py_LIMITED_API */
60 73
61 /* Error handling definitions */ 74 /* Error handling definitions */
62 75
63 PyAPI_FUNC(void) PyErr_SetNone(PyObject *); 76 PyAPI_FUNC(void) PyErr_SetNone(PyObject *);
64 PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *); 77 PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);
65 PyAPI_FUNC(void) PyErr_SetString( 78 PyAPI_FUNC(void) PyErr_SetString(
66 PyObject *exception, 79 PyObject *exception,
67 const char *string /* decoded from utf-8 */ 80 const char *string /* decoded from utf-8 */
68 ); 81 );
69 PyAPI_FUNC(PyObject *) PyErr_Occurred(void); 82 PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
70 PyAPI_FUNC(void) PyErr_Clear(void); 83 PyAPI_FUNC(void) PyErr_Clear(void);
71 PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **); 84 PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
72 PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *); 85 PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
86 PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **);
87 PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
73 88
74 #if defined(__clang__) || \ 89 #if defined(__clang__) || \
75 (defined(__GNUC__) && \ 90 (defined(__GNUC_MAJOR__) && \
76 ((__GNUC_MAJOR__ >= 3) || \ 91 ((__GNUC_MAJOR__ >= 3) || \
77 (__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5))) 92 (__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5)))
78 #define _Py_NO_RETURN __attribute__((__noreturn__)) 93 #define _Py_NO_RETURN __attribute__((__noreturn__))
79 #else 94 #else
80 #define _Py_NO_RETURN 95 #define _Py_NO_RETURN
81 #endif 96 #endif
82 97
83 PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN; 98 PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN;
84 99
85 #if defined(Py_DEBUG) || defined(Py_LIMITED_API) 100 #if defined(Py_DEBUG) || defined(Py_LIMITED_API)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 140
126 PyAPI_DATA(PyObject *) PyExc_BaseException; 141 PyAPI_DATA(PyObject *) PyExc_BaseException;
127 PyAPI_DATA(PyObject *) PyExc_Exception; 142 PyAPI_DATA(PyObject *) PyExc_Exception;
128 PyAPI_DATA(PyObject *) PyExc_StopIteration; 143 PyAPI_DATA(PyObject *) PyExc_StopIteration;
129 PyAPI_DATA(PyObject *) PyExc_GeneratorExit; 144 PyAPI_DATA(PyObject *) PyExc_GeneratorExit;
130 PyAPI_DATA(PyObject *) PyExc_ArithmeticError; 145 PyAPI_DATA(PyObject *) PyExc_ArithmeticError;
131 PyAPI_DATA(PyObject *) PyExc_LookupError; 146 PyAPI_DATA(PyObject *) PyExc_LookupError;
132 147
133 PyAPI_DATA(PyObject *) PyExc_AssertionError; 148 PyAPI_DATA(PyObject *) PyExc_AssertionError;
134 PyAPI_DATA(PyObject *) PyExc_AttributeError; 149 PyAPI_DATA(PyObject *) PyExc_AttributeError;
150 PyAPI_DATA(PyObject *) PyExc_BufferError;
135 PyAPI_DATA(PyObject *) PyExc_EOFError; 151 PyAPI_DATA(PyObject *) PyExc_EOFError;
136 PyAPI_DATA(PyObject *) PyExc_FloatingPointError; 152 PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
137 PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
138 PyAPI_DATA(PyObject *) PyExc_IOError;
139 PyAPI_DATA(PyObject *) PyExc_OSError; 153 PyAPI_DATA(PyObject *) PyExc_OSError;
140 PyAPI_DATA(PyObject *) PyExc_ImportError; 154 PyAPI_DATA(PyObject *) PyExc_ImportError;
141 PyAPI_DATA(PyObject *) PyExc_IndexError; 155 PyAPI_DATA(PyObject *) PyExc_IndexError;
142 PyAPI_DATA(PyObject *) PyExc_KeyError; 156 PyAPI_DATA(PyObject *) PyExc_KeyError;
143 PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt; 157 PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;
144 PyAPI_DATA(PyObject *) PyExc_MemoryError; 158 PyAPI_DATA(PyObject *) PyExc_MemoryError;
145 PyAPI_DATA(PyObject *) PyExc_NameError; 159 PyAPI_DATA(PyObject *) PyExc_NameError;
146 PyAPI_DATA(PyObject *) PyExc_OverflowError; 160 PyAPI_DATA(PyObject *) PyExc_OverflowError;
147 PyAPI_DATA(PyObject *) PyExc_RuntimeError; 161 PyAPI_DATA(PyObject *) PyExc_RuntimeError;
148 PyAPI_DATA(PyObject *) PyExc_NotImplementedError; 162 PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
149 PyAPI_DATA(PyObject *) PyExc_SyntaxError; 163 PyAPI_DATA(PyObject *) PyExc_SyntaxError;
150 PyAPI_DATA(PyObject *) PyExc_IndentationError; 164 PyAPI_DATA(PyObject *) PyExc_IndentationError;
151 PyAPI_DATA(PyObject *) PyExc_TabError; 165 PyAPI_DATA(PyObject *) PyExc_TabError;
152 PyAPI_DATA(PyObject *) PyExc_ReferenceError; 166 PyAPI_DATA(PyObject *) PyExc_ReferenceError;
153 PyAPI_DATA(PyObject *) PyExc_SystemError; 167 PyAPI_DATA(PyObject *) PyExc_SystemError;
154 PyAPI_DATA(PyObject *) PyExc_SystemExit; 168 PyAPI_DATA(PyObject *) PyExc_SystemExit;
155 PyAPI_DATA(PyObject *) PyExc_TypeError; 169 PyAPI_DATA(PyObject *) PyExc_TypeError;
156 PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; 170 PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
157 PyAPI_DATA(PyObject *) PyExc_UnicodeError; 171 PyAPI_DATA(PyObject *) PyExc_UnicodeError;
158 PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; 172 PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
159 PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError; 173 PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
160 PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError; 174 PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
161 PyAPI_DATA(PyObject *) PyExc_ValueError; 175 PyAPI_DATA(PyObject *) PyExc_ValueError;
162 PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError; 176 PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
177
178 PyAPI_DATA(PyObject *) PyExc_BlockingIOError;
179 PyAPI_DATA(PyObject *) PyExc_BrokenPipeError;
180 PyAPI_DATA(PyObject *) PyExc_ChildProcessError;
181 PyAPI_DATA(PyObject *) PyExc_ConnectionError;
182 PyAPI_DATA(PyObject *) PyExc_ConnectionAbortedError;
183 PyAPI_DATA(PyObject *) PyExc_ConnectionRefusedError;
184 PyAPI_DATA(PyObject *) PyExc_ConnectionResetError;
185 PyAPI_DATA(PyObject *) PyExc_FileExistsError;
186 PyAPI_DATA(PyObject *) PyExc_FileNotFoundError;
187 PyAPI_DATA(PyObject *) PyExc_InterruptedError;
188 PyAPI_DATA(PyObject *) PyExc_IsADirectoryError;
189 PyAPI_DATA(PyObject *) PyExc_NotADirectoryError;
190 PyAPI_DATA(PyObject *) PyExc_PermissionError;
191 PyAPI_DATA(PyObject *) PyExc_ProcessLookupError;
192 PyAPI_DATA(PyObject *) PyExc_TimeoutError;
193
194
195 /* Compatibility aliases */
196 PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
197 PyAPI_DATA(PyObject *) PyExc_IOError;
163 #ifdef MS_WINDOWS 198 #ifdef MS_WINDOWS
164 PyAPI_DATA(PyObject *) PyExc_WindowsError; 199 PyAPI_DATA(PyObject *) PyExc_WindowsError;
165 #endif 200 #endif
166 #ifdef __VMS 201 #ifdef __VMS
167 PyAPI_DATA(PyObject *) PyExc_VMSError; 202 PyAPI_DATA(PyObject *) PyExc_VMSError;
168 #endif 203 #endif
169
170 PyAPI_DATA(PyObject *) PyExc_BufferError;
171 204
172 PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst; 205 PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst;
173 206
174 /* Predefined warning categories */ 207 /* Predefined warning categories */
175 PyAPI_DATA(PyObject *) PyExc_Warning; 208 PyAPI_DATA(PyObject *) PyExc_Warning;
176 PyAPI_DATA(PyObject *) PyExc_UserWarning; 209 PyAPI_DATA(PyObject *) PyExc_UserWarning;
177 PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; 210 PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;
178 PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; 211 PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
179 PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; 212 PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;
180 PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; 213 PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 PyObject *exc, 257 PyObject *exc,
225 int ierr, 258 int ierr,
226 const char *filename /* decoded from the filesystem encoding */ 259 const char *filename /* decoded from the filesystem encoding */
227 ); 260 );
228 #ifndef Py_LIMITED_API 261 #ifndef Py_LIMITED_API
229 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( 262 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
230 PyObject *,int, const Py_UNICODE *); 263 PyObject *,int, const Py_UNICODE *);
231 #endif 264 #endif
232 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int); 265 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
233 #endif /* MS_WINDOWS */ 266 #endif /* MS_WINDOWS */
267
268 PyAPI_FUNC(PyObject *) PyErr_SetExcWithArgsKwargs(PyObject *, PyObject *,
269 PyObject *);
270 PyAPI_FUNC(PyObject *) PyErr_SetImportError(PyObject *, PyObject *,
271 PyObject *);
234 272
235 /* Export the old function so that the existing API remains available: */ 273 /* Export the old function so that the existing API remains available: */
236 PyAPI_FUNC(void) PyErr_BadInternalCall(void); 274 PyAPI_FUNC(void) PyErr_BadInternalCall(void);
237 PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno); 275 PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno);
238 /* Mask the old API with a call to the new API for code compiled under 276 /* Mask the old API with a call to the new API for code compiled under
239 Python 2.0: */ 277 Python 2.0: */
240 #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) 278 #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
241 279
242 /* Function to create a new exception */ 280 /* Function to create a new exception */
243 PyAPI_FUNC(PyObject *) PyErr_NewException( 281 PyAPI_FUNC(PyObject *) PyErr_NewException(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 339
302 /* create a UnicodeTranslateError object */ 340 /* create a UnicodeTranslateError object */
303 #ifndef Py_LIMITED_API 341 #ifndef Py_LIMITED_API
304 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( 342 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
305 const Py_UNICODE *object, 343 const Py_UNICODE *object,
306 Py_ssize_t length, 344 Py_ssize_t length,
307 Py_ssize_t start, 345 Py_ssize_t start,
308 Py_ssize_t end, 346 Py_ssize_t end,
309 const char *reason /* UTF-8 encoded string */ 347 const char *reason /* UTF-8 encoded string */
310 ); 348 );
349 PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
350 PyObject *object,
351 Py_ssize_t start,
352 Py_ssize_t end,
353 const char *reason /* UTF-8 encoded string */
354 );
311 #endif 355 #endif
312 356
313 /* get the encoding attribute */ 357 /* get the encoding attribute */
314 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); 358 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
315 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *); 359 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);
316 360
317 /* get the object attribute */ 361 /* get the object attribute */
318 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *); 362 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);
319 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *); 363 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);
320 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *); 364 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const char *reason /* UTF-8 encoded string */ 399 const char *reason /* UTF-8 encoded string */
356 ); 400 );
357 PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( 401 PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
358 PyObject *exc, 402 PyObject *exc,
359 const char *reason /* UTF-8 encoded string */ 403 const char *reason /* UTF-8 encoded string */
360 ); 404 );
361 PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( 405 PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
362 PyObject *exc, 406 PyObject *exc,
363 const char *reason /* UTF-8 encoded string */ 407 const char *reason /* UTF-8 encoded string */
364 ); 408 );
365
366 409
367 /* These APIs aren't really part of the error implementation, but 410 /* These APIs aren't really part of the error implementation, but
368 often needed to format error messages; the native C lib APIs are 411 often needed to format error messages; the native C lib APIs are
369 not available on all platforms, which is why we provide emulations 412 not available on all platforms, which is why we provide emulations
370 for those platforms in Python/mysnprintf.c, 413 for those platforms in Python/mysnprintf.c,
371 WARNING: The return value of snprintf varies across platforms; do 414 WARNING: The return value of snprintf varies across platforms; do
372 not rely on any particular behavior; eventually the C99 defn may 415 not rely on any particular behavior; eventually the C99 defn may
373 be reliable. 416 be reliable.
374 */ 417 */
375 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF) 418 #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
376 # define HAVE_SNPRINTF 419 # define HAVE_SNPRINTF
377 # define snprintf _snprintf 420 # define snprintf _snprintf
378 # define vsnprintf _vsnprintf 421 # define vsnprintf _vsnprintf
379 #endif 422 #endif
380 423
381 #include <stdarg.h> 424 #include <stdarg.h>
382 PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) 425 PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...)
383 Py_GCC_ATTRIBUTE((format(printf, 3, 4))); 426 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) 427 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))); 428 Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
386 429
387 #ifdef __cplusplus 430 #ifdef __cplusplus
388 } 431 }
389 #endif 432 #endif
390 #endif /* !Py_ERRORS_H */ 433 #endif /* !Py_ERRORS_H */
LEFTRIGHT

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