Bug Summary

File:Objects/exceptions.c
Location:line 504, column 5
Description:Access to field 'ob_refcnt' results in a dereference of a null pointer (loaded from field 'code')

Annotated Source Code

1/*
2 * New exceptions.c written in Iceland by Richard Jones and Georg Brandl.
3 *
4 * Thanks go to Tim Peters and Michael Hudson for debugging.
5 */
6
7#define PY_SSIZE_T_CLEAN
8#include <Python.h>
9#include "structmember.h"
10#include "osdefs.h"
11
12
13/* NOTE: If the exception class hierarchy changes, don't forget to update
14 * Lib/test/exception_hierarchy.txt
15 */
16
17/*
18 * BaseException
19 */
20static PyObject *
21BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
22{
23 PyBaseExceptionObject *self;
24
25 self = (PyBaseExceptionObject *)type->tp_alloc(type, 0);
26 if (!self)
27 return NULL((void*)0);
28 /* the dict is created on the fly in PyObject_GenericSetAttr */
29 self->dict = NULL((void*)0);
30 self->traceback = self->cause = self->context = NULL((void*)0);
31
32 self->args = PyTuple_New(0);
33 if (!self->args) {
34 Py_DECREF(self)do { if (_Py_RefTotal-- , --((PyObject*)(self))->ob_refcnt
!= 0) { if (((PyObject*)self)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 34, (PyObject *)(self)); } else _Py_Dealloc
((PyObject *)(self)); } while (0)
;
35 return NULL((void*)0);
36 }
37
38 return (PyObject *)self;
39}
40
41static int
42BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
43{
44 if (!_PyArg_NoKeywords(Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_name, kwds))
45 return -1;
46
47 Py_DECREF(self->args)do { if (_Py_RefTotal-- , --((PyObject*)(self->args))->
ob_refcnt != 0) { if (((PyObject*)self->args)->ob_refcnt
< 0) _Py_NegativeRefcount("Objects/exceptions.c", 47, (PyObject
*)(self->args)); } else _Py_Dealloc((PyObject *)(self->
args)); } while (0)
;
48 self->args = args;
49 Py_INCREF(self->args)( _Py_RefTotal++ , ((PyObject*)(self->args))->ob_refcnt
++)
;
50
51 return 0;
52}
53
54static int
55BaseException_clear(PyBaseExceptionObject *self)
56{
57 Py_CLEAR(self->dict)do { if (self->dict) { PyObject *_py_tmp = (PyObject *)(self
->dict); (self->dict) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 57, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)
(_py_tmp)); } while (0); } } while (0)
;
58 Py_CLEAR(self->args)do { if (self->args) { PyObject *_py_tmp = (PyObject *)(self
->args); (self->args) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 58, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)
(_py_tmp)); } while (0); } } while (0)
;
59 Py_CLEAR(self->traceback)do { if (self->traceback) { PyObject *_py_tmp = (PyObject *
)(self->traceback); (self->traceback) = ((void*)0); do {
if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt !=
0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 59, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
60 Py_CLEAR(self->cause)do { if (self->cause) { PyObject *_py_tmp = (PyObject *)(self
->cause); (self->cause) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 60, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)
(_py_tmp)); } while (0); } } while (0)
;
61 Py_CLEAR(self->context)do { if (self->context) { PyObject *_py_tmp = (PyObject *)
(self->context); (self->context) = ((void*)0); do { if (
_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0)
{ if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 61, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
62 return 0;
63}
64
65static void
66BaseException_dealloc(PyBaseExceptionObject *self)
67{
68 _PyObject_GC_UNTRACK(self)do { PyGC_Head *g = ((PyGC_Head *)(self)-1); (__builtin_expect
(!(g->gc.gc_refs != (-2)), 0) ? __assert_rtn(__func__, "Objects/exceptions.c"
, 68, "g->gc.gc_refs != _PyGC_REFS_UNTRACKED") : (void)0);
g->gc.gc_refs = (-2); g->gc.gc_prev->gc.gc_next = g
->gc.gc_next; g->gc.gc_next->gc.gc_prev = g->gc.gc_prev
; g->gc.gc_next = ((void*)0); } while (0);
;
69 BaseException_clear(self);
70 Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self);
71}
72
73static int
74BaseException_traverse(PyBaseExceptionObject *self, visitproc visit, void *arg)
75{
76 Py_VISIT(self->dict)do { if (self->dict) { int vret = visit((PyObject *)(self->
dict), arg); if (vret) return vret; } } while (0)
;
77 Py_VISIT(self->args)do { if (self->args) { int vret = visit((PyObject *)(self->
args), arg); if (vret) return vret; } } while (0)
;
78 Py_VISIT(self->traceback)do { if (self->traceback) { int vret = visit((PyObject *)(
self->traceback), arg); if (vret) return vret; } } while (
0)
;
79 Py_VISIT(self->cause)do { if (self->cause) { int vret = visit((PyObject *)(self
->cause), arg); if (vret) return vret; } } while (0)
;
80 Py_VISIT(self->context)do { if (self->context) { int vret = visit((PyObject *)(self
->context), arg); if (vret) return vret; } } while (0)
;
81 return 0;
82}
83
84static PyObject *
85BaseException_str(PyBaseExceptionObject *self)
86{
87 switch (PyTuple_GET_SIZE(self->args)(((PyVarObject*)(self->args))->ob_size)) {
88 case 0:
89 return PyUnicode_FromStringPyUnicodeUCS2_FromString("");
90 case 1:
91 return PyObject_Str(PyTuple_GET_ITEM(self->args, 0)(((PyTupleObject *)(self->args))->ob_item[0]));
92 default:
93 return PyObject_Str(self->args);
94 }
95}
96
97static PyObject *
98BaseException_repr(PyBaseExceptionObject *self)
99{
100 char *name;
101 char *dot;
102
103 name = (char *)Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_name;
104 dot = strrchr(name, '.');
105 if (dot != NULL((void*)0)) name = dot+1;
106
107 return PyUnicode_FromFormatPyUnicodeUCS2_FromFormat("%s%R", name, self->args);
108}
109
110/* Pickling support */
111static PyObject *
112BaseException_reduce(PyBaseExceptionObject *self)
113{
114 if (self->args && self->dict)
115 return PyTuple_Pack(3, Py_TYPE(self)(((PyObject*)(self))->ob_type), self->args, self->dict);
116 else
117 return PyTuple_Pack(2, Py_TYPE(self)(((PyObject*)(self))->ob_type), self->args);
118}
119
120/*
121 * Needed for backward compatibility, since exceptions used to store
122 * all their attributes in the __dict__. Code is taken from cPickle's
123 * load_build function.
124 */
125static PyObject *
126BaseException_setstate(PyObject *self, PyObject *state)
127{
128 PyObject *d_key, *d_value;
129 Py_ssize_t i = 0;
130
131 if (state != Py_None(&_Py_NoneStruct)) {
132 if (!PyDict_Check(state)((((((PyObject*)(state))->ob_type))->tp_flags & ((1L
<<29))) != 0)
) {
133 PyErr_SetString(PyExc_TypeError, "state is not a dictionary");
134 return NULL((void*)0);
135 }
136 while (PyDict_Next(state, &i, &d_key, &d_value)) {
137 if (PyObject_SetAttr(self, d_key, d_value) < 0)
138 return NULL((void*)0);
139 }
140 }
141 Py_RETURN_NONEreturn ( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct))
)->ob_refcnt++), (&_Py_NoneStruct)
;
142}
143
144static PyObject *
145BaseException_with_traceback(PyObject *self, PyObject *tb) {
146 if (PyException_SetTraceback(self, tb))
147 return NULL((void*)0);
148
149 Py_INCREF(self)( _Py_RefTotal++ , ((PyObject*)(self))->ob_refcnt++);
150 return self;
151}
152
153PyDoc_STRVAR(with_traceback_doc,static char with_traceback_doc[] = "Exception.with_traceback(tb) --\n set self.__traceback__ to tb and return self."
154"Exception.with_traceback(tb) --\n\static char with_traceback_doc[] = "Exception.with_traceback(tb) --\n set self.__traceback__ to tb and return self."
155 set self.__traceback__ to tb and return self.")static char with_traceback_doc[] = "Exception.with_traceback(tb) --\n set self.__traceback__ to tb and return self.";
156
157
158static PyMethodDef BaseException_methods[] = {
159 {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS0x0004 },
160 {"__setstate__", (PyCFunction)BaseException_setstate, METH_O0x0008 },
161 {"with_traceback", (PyCFunction)BaseException_with_traceback, METH_O0x0008,
162 with_traceback_doc},
163 {NULL((void*)0), NULL((void*)0), 0, NULL((void*)0)},
164};
165
166
167static PyObject *
168BaseException_get_dict(PyBaseExceptionObject *self)
169{
170 if (self->dict == NULL((void*)0)) {
171 self->dict = PyDict_New();
172 if (!self->dict)
173 return NULL((void*)0);
174 }
175 Py_INCREF(self->dict)( _Py_RefTotal++ , ((PyObject*)(self->dict))->ob_refcnt
++)
;
176 return self->dict;
177}
178
179static int
180BaseException_set_dict(PyBaseExceptionObject *self, PyObject *val)
181{
182 if (val == NULL((void*)0)) {
183 PyErr_SetString(PyExc_TypeError, "__dict__ may not be deleted");
184 return -1;
185 }
186 if (!PyDict_Check(val)((((((PyObject*)(val))->ob_type))->tp_flags & ((1L<<
29))) != 0)
) {
187 PyErr_SetString(PyExc_TypeError, "__dict__ must be a dictionary");
188 return -1;
189 }
190 Py_CLEAR(self->dict)do { if (self->dict) { PyObject *_py_tmp = (PyObject *)(self
->dict); (self->dict) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 190, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
191 Py_INCREF(val)( _Py_RefTotal++ , ((PyObject*)(val))->ob_refcnt++);
192 self->dict = val;
193 return 0;
194}
195
196static PyObject *
197BaseException_get_args(PyBaseExceptionObject *self)
198{
199 if (self->args == NULL((void*)0)) {
200 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
201 return Py_None(&_Py_NoneStruct);
202 }
203 Py_INCREF(self->args)( _Py_RefTotal++ , ((PyObject*)(self->args))->ob_refcnt
++)
;
204 return self->args;
205}
206
207static int
208BaseException_set_args(PyBaseExceptionObject *self, PyObject *val)
209{
210 PyObject *seq;
211 if (val == NULL((void*)0)) {
212 PyErr_SetString(PyExc_TypeError, "args may not be deleted");
213 return -1;
214 }
215 seq = PySequence_Tuple(val);
216 if (!seq) return -1;
217 Py_CLEAR(self->args)do { if (self->args) { PyObject *_py_tmp = (PyObject *)(self
->args); (self->args) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 217, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
218 self->args = seq;
219 return 0;
220}
221
222static PyObject *
223BaseException_get_tb(PyBaseExceptionObject *self)
224{
225 if (self->traceback == NULL((void*)0)) {
226 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
227 return Py_None(&_Py_NoneStruct);
228 }
229 Py_INCREF(self->traceback)( _Py_RefTotal++ , ((PyObject*)(self->traceback))->ob_refcnt
++)
;
230 return self->traceback;
231}
232
233static int
234BaseException_set_tb(PyBaseExceptionObject *self, PyObject *tb)
235{
236 if (tb == NULL((void*)0)) {
237 PyErr_SetString(PyExc_TypeError, "__traceback__ may not be deleted");
238 return -1;
239 }
240 else if (!(tb == Py_None(&_Py_NoneStruct) || PyTraceBack_Check(tb)((((PyObject*)(tb))->ob_type) == &PyTraceBack_Type))) {
241 PyErr_SetString(PyExc_TypeError,
242 "__traceback__ must be a traceback or None");
243 return -1;
244 }
245
246 Py_XINCREF(tb)do { if ((tb) == ((void*)0)) ; else ( _Py_RefTotal++ , ((PyObject
*)(tb))->ob_refcnt++); } while (0)
;
247 Py_XDECREF(self->traceback)do { if ((self->traceback) == ((void*)0)) ; else do { if (
_Py_RefTotal-- , --((PyObject*)(self->traceback))->ob_refcnt
!= 0) { if (((PyObject*)self->traceback)->ob_refcnt <
0) _Py_NegativeRefcount("Objects/exceptions.c", 247, (PyObject
*)(self->traceback)); } else _Py_Dealloc((PyObject *)(self
->traceback)); } while (0); } while (0)
;
248 self->traceback = tb;
249 return 0;
250}
251
252static PyObject *
253BaseException_get_context(PyObject *self) {
254 PyObject *res = PyException_GetContext(self);
255 if (res) return res; /* new reference already returned above */
256 Py_RETURN_NONEreturn ( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct))
)->ob_refcnt++), (&_Py_NoneStruct)
;
257}
258
259static int
260BaseException_set_context(PyObject *self, PyObject *arg) {
261 if (arg == NULL((void*)0)) {
262 PyErr_SetString(PyExc_TypeError, "__context__ may not be deleted");
263 return -1;
264 } else if (arg == Py_None(&_Py_NoneStruct)) {
265 arg = NULL((void*)0);
266 } else if (!PyExceptionInstance_Check(arg)((((arg)->ob_type)->tp_flags & ((1L<<30))) !=
0)
) {
267 PyErr_SetString(PyExc_TypeError, "exception context must be None "
268 "or derive from BaseException");
269 return -1;
270 } else {
271 /* PyException_SetContext steals this reference */
272 Py_INCREF(arg)( _Py_RefTotal++ , ((PyObject*)(arg))->ob_refcnt++);
273 }
274 PyException_SetContext(self, arg);
275 return 0;
276}
277
278static PyObject *
279BaseException_get_cause(PyObject *self) {
280 PyObject *res = PyException_GetCause(self);
281 if (res) return res; /* new reference already returned above */
282 Py_RETURN_NONEreturn ( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct))
)->ob_refcnt++), (&_Py_NoneStruct)
;
283}
284
285static int
286BaseException_set_cause(PyObject *self, PyObject *arg) {
287 if (arg == NULL((void*)0)) {
288 PyErr_SetString(PyExc_TypeError, "__cause__ may not be deleted");
289 return -1;
290 } else if (arg == Py_None(&_Py_NoneStruct)) {
291 arg = NULL((void*)0);
292 } else if (!PyExceptionInstance_Check(arg)((((arg)->ob_type)->tp_flags & ((1L<<30))) !=
0)
) {
293 PyErr_SetString(PyExc_TypeError, "exception cause must be None "
294 "or derive from BaseException");
295 return -1;
296 } else {
297 /* PyException_SetCause steals this reference */
298 Py_INCREF(arg)( _Py_RefTotal++ , ((PyObject*)(arg))->ob_refcnt++);
299 }
300 PyException_SetCause(self, arg);
301 return 0;
302}
303
304
305static PyGetSetDef BaseException_getset[] = {
306 {"__dict__", (getter)BaseException_get_dict, (setter)BaseException_set_dict},
307 {"args", (getter)BaseException_get_args, (setter)BaseException_set_args},
308 {"__traceback__", (getter)BaseException_get_tb, (setter)BaseException_set_tb},
309 {"__context__", (getter)BaseException_get_context,
310 (setter)BaseException_set_context, PyDoc_STR("exception context")"exception context"},
311 {"__cause__", (getter)BaseException_get_cause,
312 (setter)BaseException_set_cause, PyDoc_STR("exception cause")"exception cause"},
313 {NULL((void*)0)},
314};
315
316
317PyObject *
318PyException_GetTraceback(PyObject *self) {
319 PyBaseExceptionObject *base_self = (PyBaseExceptionObject *)self;
320 Py_XINCREF(base_self->traceback)do { if ((base_self->traceback) == ((void*)0)) ; else ( _Py_RefTotal
++ , ((PyObject*)(base_self->traceback))->ob_refcnt++);
} while (0)
;
321 return base_self->traceback;
322}
323
324
325int
326PyException_SetTraceback(PyObject *self, PyObject *tb) {
327 return BaseException_set_tb((PyBaseExceptionObject *)self, tb);
328}
329
330PyObject *
331PyException_GetCause(PyObject *self) {
332 PyObject *cause = ((PyBaseExceptionObject *)self)->cause;
333 Py_XINCREF(cause)do { if ((cause) == ((void*)0)) ; else ( _Py_RefTotal++ , ((PyObject
*)(cause))->ob_refcnt++); } while (0)
;
334 return cause;
335}
336
337/* Steals a reference to cause */
338void
339PyException_SetCause(PyObject *self, PyObject *cause) {
340 PyObject *old_cause = ((PyBaseExceptionObject *)self)->cause;
341 ((PyBaseExceptionObject *)self)->cause = cause;
342 Py_XDECREF(old_cause)do { if ((old_cause) == ((void*)0)) ; else do { if (_Py_RefTotal
-- , --((PyObject*)(old_cause))->ob_refcnt != 0) { if (((PyObject
*)old_cause)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 342, (PyObject *)(old_cause)); } else _Py_Dealloc((PyObject
*)(old_cause)); } while (0); } while (0)
;
343}
344
345PyObject *
346PyException_GetContext(PyObject *self) {
347 PyObject *context = ((PyBaseExceptionObject *)self)->context;
348 Py_XINCREF(context)do { if ((context) == ((void*)0)) ; else ( _Py_RefTotal++ , (
(PyObject*)(context))->ob_refcnt++); } while (0)
;
349 return context;
350}
351
352/* Steals a reference to context */
353void
354PyException_SetContext(PyObject *self, PyObject *context) {
355 PyObject *old_context = ((PyBaseExceptionObject *)self)->context;
356 ((PyBaseExceptionObject *)self)->context = context;
357 Py_XDECREF(old_context)do { if ((old_context) == ((void*)0)) ; else do { if (_Py_RefTotal
-- , --((PyObject*)(old_context))->ob_refcnt != 0) { if ((
(PyObject*)old_context)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 357, (PyObject *)(old_context)); } else
_Py_Dealloc((PyObject *)(old_context)); } while (0); } while
(0)
;
358}
359
360
361static PyTypeObject _PyExc_BaseException = {
362 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 },
363 "BaseException", /*tp_name*/
364 sizeof(PyBaseExceptionObject), /*tp_basicsize*/
365 0, /*tp_itemsize*/
366 (destructor)BaseException_dealloc, /*tp_dealloc*/
367 0, /*tp_print*/
368 0, /*tp_getattr*/
369 0, /*tp_setattr*/
370 0, /* tp_reserved; */
371 (reprfunc)BaseException_repr, /*tp_repr*/
372 0, /*tp_as_number*/
373 0, /*tp_as_sequence*/
374 0, /*tp_as_mapping*/
375 0, /*tp_hash */
376 0, /*tp_call*/
377 (reprfunc)BaseException_str, /*tp_str*/
378 PyObject_GenericGetAttr, /*tp_getattro*/
379 PyObject_GenericSetAttr, /*tp_setattro*/
380 0, /*tp_as_buffer*/
381 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_BASETYPE(1L<<10) | Py_TPFLAGS_HAVE_GC(1L<<14) |
382 Py_TPFLAGS_BASE_EXC_SUBCLASS(1L<<30), /*tp_flags*/
383 PyDoc_STR("Common base class for all exceptions")"Common base class for all exceptions", /* tp_doc */
384 (traverseproc)BaseException_traverse, /* tp_traverse */
385 (inquiry)BaseException_clear, /* tp_clear */
386 0, /* tp_richcompare */
387 0, /* tp_weaklistoffset */
388 0, /* tp_iter */
389 0, /* tp_iternext */
390 BaseException_methods, /* tp_methods */
391 0, /* tp_members */
392 BaseException_getset, /* tp_getset */
393 0, /* tp_base */
394 0, /* tp_dict */
395 0, /* tp_descr_get */
396 0, /* tp_descr_set */
397 offsetof(PyBaseExceptionObject, dict)__builtin_offsetof(PyBaseExceptionObject, dict), /* tp_dictoffset */
398 (initproc)BaseException_init, /* tp_init */
399 0, /* tp_alloc */
400 BaseException_new, /* tp_new */
401};
402/* the CPython API expects exceptions to be (PyObject *) - both a hold-over
403from the previous implmentation and also allowing Python objects to be used
404in the API */
405PyObject *PyExc_BaseException = (PyObject *)&_PyExc_BaseException;
406
407/* note these macros omit the last semicolon so the macro invocation may
408 * include it and not look strange.
409 */
410#define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC)static PyTypeObject _PyExc_EXCNAME = { { { 0, 0, 1, ((void*)0
) }, 0 }, "EXCNAME", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), EXCDOC, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_EXCBASE, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_EXCNAME = (PyObject *)
&_PyExc_EXCNAME
\
411static PyTypeObject _PyExc_ ## EXCNAME = { \
412 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 }, \
413 # EXCNAME, \
414 sizeof(PyBaseExceptionObject), \
415 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \
416 0, 0, 0, 0, 0, 0, 0, \
417 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_BASETYPE(1L<<10) | Py_TPFLAGS_HAVE_GC(1L<<14), \
418 PyDoc_STR(EXCDOC)EXCDOC, (traverseproc)BaseException_traverse, \
419 (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \
420 0, 0, 0, offsetof(PyBaseExceptionObject, dict)__builtin_offsetof(PyBaseExceptionObject, dict), \
421 (initproc)BaseException_init, 0, BaseException_new,\
422}; \
423PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME
424
425#define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC)static PyTypeObject _PyExc_EXCNAME = { { { 0, 0, 1, ((void*)0
) }, 0 }, "EXCNAME", sizeof(PyEXCSTOREObject), 0, (destructor
) EXCSTORE_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<14),
EXCDOC, (traverseproc) EXCSTORE_traverse, (inquiry) EXCSTORE_clear
, 0, 0, 0, 0, 0, 0, 0, &_EXCBASE, 0, 0, 0, __builtin_offsetof
(PyEXCSTOREObject, dict), (initproc) EXCSTORE_init, 0, BaseException_new
,}; PyObject *PyExc_EXCNAME = (PyObject *)&_PyExc_EXCNAME
\
426static PyTypeObject _PyExc_ ## EXCNAME = { \
427 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 }, \
428 # EXCNAME, \
429 sizeof(Py ## EXCSTORE ## Object), \
430 0, (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
431 0, 0, 0, 0, 0, \
432 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_BASETYPE(1L<<10) | Py_TPFLAGS_HAVE_GC(1L<<14), \
433 PyDoc_STR(EXCDOC)EXCDOC, (traverseproc)EXCSTORE ## _traverse, \
434 (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \
435 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict)__builtin_offsetof(Py ## EXCSTORE ## Object, dict), \
436 (initproc)EXCSTORE ## _init, 0, BaseException_new,\
437}; \
438PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME
439
440#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCSTR, EXCDOC)static PyTypeObject _PyExc_EXCNAME = { { { 0, 0, 1, ((void*)0
) }, 0 }, "EXCNAME", sizeof(PyEXCSTOREObject), 0, (destructor
) EXCSTORE_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)EXCSTR
, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), EXCDOC, (traverseproc) EXCSTORE_traverse, (inquiry) EXCSTORE_clear
, 0, 0, 0, 0, EXCMETHODS, EXCMEMBERS, 0, &_EXCBASE, 0, 0,
0, __builtin_offsetof(PyEXCSTOREObject, dict), (initproc) EXCSTORE_init
, 0, BaseException_new,}; PyObject *PyExc_EXCNAME = (PyObject
*)&_PyExc_EXCNAME
\
441static PyTypeObject _PyExc_ ## EXCNAME = { \
442 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 }, \
443 # EXCNAME, \
444 sizeof(Py ## EXCSTORE ## Object), 0, \
445 (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
446 (reprfunc)EXCSTR, 0, 0, 0, \
447 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_BASETYPE(1L<<10) | Py_TPFLAGS_HAVE_GC(1L<<14), \
448 PyDoc_STR(EXCDOC)EXCDOC, (traverseproc)EXCSTORE ## _traverse, \
449 (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, EXCMETHODS, \
450 EXCMEMBERS, 0, &_ ## EXCBASE, \
451 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict)__builtin_offsetof(Py ## EXCSTORE ## Object, dict), \
452 (initproc)EXCSTORE ## _init, 0, BaseException_new,\
453}; \
454PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME
455
456
457/*
458 * Exception extends BaseException
459 */
460SimpleExtendsException(PyExc_BaseException, Exception,static PyTypeObject _PyExc_Exception = { { { 0, 0, 1, ((void*
)0) }, 0 }, "Exception", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Common base class for all non-exit exceptions.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_BaseException, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_Exception = (PyObject *
)&_PyExc_Exception
461 "Common base class for all non-exit exceptions.")static PyTypeObject _PyExc_Exception = { { { 0, 0, 1, ((void*
)0) }, 0 }, "Exception", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Common base class for all non-exit exceptions.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_BaseException, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_Exception = (PyObject *
)&_PyExc_Exception
;
462
463
464/*
465 * TypeError extends Exception
466 */
467SimpleExtendsException(PyExc_Exception, TypeError,static PyTypeObject _PyExc_TypeError = { { { 0, 0, 1, ((void*
)0) }, 0 }, "TypeError", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Inappropriate argument type.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_TypeError = (PyObject *)&_PyExc_TypeError
468 "Inappropriate argument type.")static PyTypeObject _PyExc_TypeError = { { { 0, 0, 1, ((void*
)0) }, 0 }, "TypeError", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Inappropriate argument type.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_TypeError = (PyObject *)&_PyExc_TypeError
;
469
470
471/*
472 * StopIteration extends Exception
473 */
474SimpleExtendsException(PyExc_Exception, StopIteration,static PyTypeObject _PyExc_StopIteration = { { { 0, 0, 1, ((void
*)0) }, 0 }, "StopIteration", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Signal the end from iterator.__next__().", (
traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_StopIteration = (PyObject
*)&_PyExc_StopIteration
475 "Signal the end from iterator.__next__().")static PyTypeObject _PyExc_StopIteration = { { { 0, 0, 1, ((void
*)0) }, 0 }, "StopIteration", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Signal the end from iterator.__next__().", (
traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_StopIteration = (PyObject
*)&_PyExc_StopIteration
;
476
477
478/*
479 * GeneratorExit extends BaseException
480 */
481SimpleExtendsException(PyExc_BaseException, GeneratorExit,static PyTypeObject _PyExc_GeneratorExit = { { { 0, 0, 1, ((void
*)0) }, 0 }, "GeneratorExit", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Request that a generator exit.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_BaseException, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_GeneratorExit = (PyObject
*)&_PyExc_GeneratorExit
482 "Request that a generator exit.")static PyTypeObject _PyExc_GeneratorExit = { { { 0, 0, 1, ((void
*)0) }, 0 }, "GeneratorExit", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Request that a generator exit.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_BaseException, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_GeneratorExit = (PyObject
*)&_PyExc_GeneratorExit
;
483
484
485/*
486 * SystemExit extends BaseException
487 */
488
489static int
490SystemExit_init(PySystemExitObject *self, PyObject *args, PyObject *kwds)
491{
492 Py_ssize_t size = PyTuple_GET_SIZE(args)(((PyVarObject*)(args))->ob_size);
493
494 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
1
Taking false branch
495 return -1;
496
497 if (size == 0)
2
Taking false branch
498 return 0;
499 Py_CLEAR(self->code)do { if (self->code) { PyObject *_py_tmp = (PyObject *)(self
->code); (self->code) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 499, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
500 if (size == 1)
3
Taking false branch
501 self->code = PyTuple_GET_ITEM(args, 0)(((PyTupleObject *)(args))->ob_item[0]);
502 else if (size > 1)
4
Taking false branch
503 self->code = args;
504 Py_INCREF(self->code)( _Py_RefTotal++ , ((PyObject*)(self->code))->ob_refcnt
++)
;
5
Within the expansion of the macro 'Py_INCREF':
a
Access to field 'ob_refcnt' results in a dereference of a null pointer (loaded from field 'code')
505 return 0;
506}
507
508static int
509SystemExit_clear(PySystemExitObject *self)
510{
511 Py_CLEAR(self->code)do { if (self->code) { PyObject *_py_tmp = (PyObject *)(self
->code); (self->code) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 511, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
512 return BaseException_clear((PyBaseExceptionObject *)self);
513}
514
515static void
516SystemExit_dealloc(PySystemExitObject *self)
517{
518 _PyObject_GC_UNTRACK(self)do { PyGC_Head *g = ((PyGC_Head *)(self)-1); (__builtin_expect
(!(g->gc.gc_refs != (-2)), 0) ? __assert_rtn(__func__, "Objects/exceptions.c"
, 518, "g->gc.gc_refs != _PyGC_REFS_UNTRACKED") : (void)0)
; g->gc.gc_refs = (-2); g->gc.gc_prev->gc.gc_next = g
->gc.gc_next; g->gc.gc_next->gc.gc_prev = g->gc.gc_prev
; g->gc.gc_next = ((void*)0); } while (0);
;
519 SystemExit_clear(self);
520 Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self);
521}
522
523static int
524SystemExit_traverse(PySystemExitObject *self, visitproc visit, void *arg)
525{
526 Py_VISIT(self->code)do { if (self->code) { int vret = visit((PyObject *)(self->
code), arg); if (vret) return vret; } } while (0)
;
527 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
528}
529
530static PyMemberDef SystemExit_members[] = {
531 {"code", T_OBJECT6, offsetof(PySystemExitObject, code)__builtin_offsetof(PySystemExitObject, code), 0,
532 PyDoc_STR("exception code")"exception code"},
533 {NULL((void*)0)} /* Sentinel */
534};
535
536ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit,static PyTypeObject _PyExc_SystemExit = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SystemExit", sizeof(PySystemExitObject), 0, (destructor
) SystemExit_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc
)0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L
<<14), "Request to exit from the interpreter.", (traverseproc
) SystemExit_traverse, (inquiry) SystemExit_clear, 0, 0, 0, 0
, 0, SystemExit_members, 0, &_PyExc_BaseException, 0, 0, 0
, __builtin_offsetof(PySystemExitObject, dict), (initproc) SystemExit_init
, 0, BaseException_new,}; PyObject *PyExc_SystemExit = (PyObject
*)&_PyExc_SystemExit
537 SystemExit_dealloc, 0, SystemExit_members, 0,static PyTypeObject _PyExc_SystemExit = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SystemExit", sizeof(PySystemExitObject), 0, (destructor
) SystemExit_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc
)0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L
<<14), "Request to exit from the interpreter.", (traverseproc
) SystemExit_traverse, (inquiry) SystemExit_clear, 0, 0, 0, 0
, 0, SystemExit_members, 0, &_PyExc_BaseException, 0, 0, 0
, __builtin_offsetof(PySystemExitObject, dict), (initproc) SystemExit_init
, 0, BaseException_new,}; PyObject *PyExc_SystemExit = (PyObject
*)&_PyExc_SystemExit
538 "Request to exit from the interpreter.")static PyTypeObject _PyExc_SystemExit = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SystemExit", sizeof(PySystemExitObject), 0, (destructor
) SystemExit_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc
)0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L
<<14), "Request to exit from the interpreter.", (traverseproc
) SystemExit_traverse, (inquiry) SystemExit_clear, 0, 0, 0, 0
, 0, SystemExit_members, 0, &_PyExc_BaseException, 0, 0, 0
, __builtin_offsetof(PySystemExitObject, dict), (initproc) SystemExit_init
, 0, BaseException_new,}; PyObject *PyExc_SystemExit = (PyObject
*)&_PyExc_SystemExit
;
539
540/*
541 * KeyboardInterrupt extends BaseException
542 */
543SimpleExtendsException(PyExc_BaseException, KeyboardInterrupt,static PyTypeObject _PyExc_KeyboardInterrupt = { { { 0, 0, 1,
((void*)0) }, 0 }, "KeyboardInterrupt", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Program interrupted by user.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_BaseException, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_KeyboardInterrupt = (PyObject
*)&_PyExc_KeyboardInterrupt
544 "Program interrupted by user.")static PyTypeObject _PyExc_KeyboardInterrupt = { { { 0, 0, 1,
((void*)0) }, 0 }, "KeyboardInterrupt", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Program interrupted by user.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_BaseException, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_KeyboardInterrupt = (PyObject
*)&_PyExc_KeyboardInterrupt
;
545
546
547/*
548 * ImportError extends Exception
549 */
550SimpleExtendsException(PyExc_Exception, ImportError,static PyTypeObject _PyExc_ImportError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "ImportError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Import can't find module, or can't find name in module."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ImportError = (PyObject
*)&_PyExc_ImportError
551 "Import can't find module, or can't find name in module.")static PyTypeObject _PyExc_ImportError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "ImportError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Import can't find module, or can't find name in module."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ImportError = (PyObject
*)&_PyExc_ImportError
;
552
553
554/*
555 * EnvironmentError extends Exception
556 */
557
558/* Where a function has a single filename, such as open() or some
559 * of the os module functions, PyErr_SetFromErrnoWithFilename() is
560 * called, giving a third argument which is the filename. But, so
561 * that old code using in-place unpacking doesn't break, e.g.:
562 *
563 * except IOError, (errno, strerror):
564 *
565 * we hack args so that it only contains two items. This also
566 * means we need our own __str__() which prints out the filename
567 * when it was supplied.
568 */
569static int
570EnvironmentError_init(PyEnvironmentErrorObject *self, PyObject *args,
571 PyObject *kwds)
572{
573 PyObject *myerrno = NULL((void*)0), *strerror = NULL((void*)0), *filename = NULL((void*)0);
574 PyObject *subslice = NULL((void*)0);
575
576 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
577 return -1;
578
579 if (PyTuple_GET_SIZE(args)(((PyVarObject*)(args))->ob_size) <= 1 || PyTuple_GET_SIZE(args)(((PyVarObject*)(args))->ob_size) > 3) {
580 return 0;
581 }
582
583 if (!PyArg_UnpackTuple(args, "EnvironmentError", 2, 3,
584 &myerrno, &strerror, &filename)) {
585 return -1;
586 }
587 Py_CLEAR(self->myerrno)do { if (self->myerrno) { PyObject *_py_tmp = (PyObject *)
(self->myerrno); (self->myerrno) = ((void*)0); do { if (
_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0)
{ if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 587, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
; /* replacing */
588 self->myerrno = myerrno;
589 Py_INCREF(self->myerrno)( _Py_RefTotal++ , ((PyObject*)(self->myerrno))->ob_refcnt
++)
;
590
591 Py_CLEAR(self->strerror)do { if (self->strerror) { PyObject *_py_tmp = (PyObject *
)(self->strerror); (self->strerror) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 591, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
; /* replacing */
592 self->strerror = strerror;
593 Py_INCREF(self->strerror)( _Py_RefTotal++ , ((PyObject*)(self->strerror))->ob_refcnt
++)
;
594
595 /* self->filename will remain Py_None otherwise */
596 if (filename != NULL((void*)0)) {
597 Py_CLEAR(self->filename)do { if (self->filename) { PyObject *_py_tmp = (PyObject *
)(self->filename); (self->filename) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 597, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
; /* replacing */
598 self->filename = filename;
599 Py_INCREF(self->filename)( _Py_RefTotal++ , ((PyObject*)(self->filename))->ob_refcnt
++)
;
600
601 subslice = PyTuple_GetSlice(args, 0, 2);
602 if (!subslice)
603 return -1;
604
605 Py_DECREF(self->args)do { if (_Py_RefTotal-- , --((PyObject*)(self->args))->
ob_refcnt != 0) { if (((PyObject*)self->args)->ob_refcnt
< 0) _Py_NegativeRefcount("Objects/exceptions.c", 605, (PyObject
*)(self->args)); } else _Py_Dealloc((PyObject *)(self->
args)); } while (0)
; /* replacing args */
606 self->args = subslice;
607 }
608 return 0;
609}
610
611static int
612EnvironmentError_clear(PyEnvironmentErrorObject *self)
613{
614 Py_CLEAR(self->myerrno)do { if (self->myerrno) { PyObject *_py_tmp = (PyObject *)
(self->myerrno); (self->myerrno) = ((void*)0); do { if (
_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0)
{ if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 614, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
615 Py_CLEAR(self->strerror)do { if (self->strerror) { PyObject *_py_tmp = (PyObject *
)(self->strerror); (self->strerror) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 615, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
616 Py_CLEAR(self->filename)do { if (self->filename) { PyObject *_py_tmp = (PyObject *
)(self->filename); (self->filename) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 616, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
617 return BaseException_clear((PyBaseExceptionObject *)self);
618}
619
620static void
621EnvironmentError_dealloc(PyEnvironmentErrorObject *self)
622{
623 _PyObject_GC_UNTRACK(self)do { PyGC_Head *g = ((PyGC_Head *)(self)-1); (__builtin_expect
(!(g->gc.gc_refs != (-2)), 0) ? __assert_rtn(__func__, "Objects/exceptions.c"
, 623, "g->gc.gc_refs != _PyGC_REFS_UNTRACKED") : (void)0)
; g->gc.gc_refs = (-2); g->gc.gc_prev->gc.gc_next = g
->gc.gc_next; g->gc.gc_next->gc.gc_prev = g->gc.gc_prev
; g->gc.gc_next = ((void*)0); } while (0);
;
624 EnvironmentError_clear(self);
625 Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self);
626}
627
628static int
629EnvironmentError_traverse(PyEnvironmentErrorObject *self, visitproc visit,
630 void *arg)
631{
632 Py_VISIT(self->myerrno)do { if (self->myerrno) { int vret = visit((PyObject *)(self
->myerrno), arg); if (vret) return vret; } } while (0)
;
633 Py_VISIT(self->strerror)do { if (self->strerror) { int vret = visit((PyObject *)(self
->strerror), arg); if (vret) return vret; } } while (0)
;
634 Py_VISIT(self->filename)do { if (self->filename) { int vret = visit((PyObject *)(self
->filename), arg); if (vret) return vret; } } while (0)
;
635 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
636}
637
638static PyObject *
639EnvironmentError_str(PyEnvironmentErrorObject *self)
640{
641 if (self->filename)
642 return PyUnicode_FromFormatPyUnicodeUCS2_FromFormat("[Errno %S] %S: %R",
643 self->myerrno ? self->myerrno: Py_None(&_Py_NoneStruct),
644 self->strerror ? self->strerror: Py_None(&_Py_NoneStruct),
645 self->filename);
646 else if (self->myerrno && self->strerror)
647 return PyUnicode_FromFormatPyUnicodeUCS2_FromFormat("[Errno %S] %S",
648 self->myerrno ? self->myerrno: Py_None(&_Py_NoneStruct),
649 self->strerror ? self->strerror: Py_None(&_Py_NoneStruct));
650 else
651 return BaseException_str((PyBaseExceptionObject *)self);
652}
653
654static PyMemberDef EnvironmentError_members[] = {
655 {"errno", T_OBJECT6, offsetof(PyEnvironmentErrorObject, myerrno)__builtin_offsetof(PyEnvironmentErrorObject, myerrno), 0,
656 PyDoc_STR("exception errno")"exception errno"},
657 {"strerror", T_OBJECT6, offsetof(PyEnvironmentErrorObject, strerror)__builtin_offsetof(PyEnvironmentErrorObject, strerror), 0,
658 PyDoc_STR("exception strerror")"exception strerror"},
659 {"filename", T_OBJECT6, offsetof(PyEnvironmentErrorObject, filename)__builtin_offsetof(PyEnvironmentErrorObject, filename), 0,
660 PyDoc_STR("exception filename")"exception filename"},
661 {NULL((void*)0)} /* Sentinel */
662};
663
664
665static PyObject *
666EnvironmentError_reduce(PyEnvironmentErrorObject *self)
667{
668 PyObject *args = self->args;
669 PyObject *res = NULL((void*)0), *tmp;
670
671 /* self->args is only the first two real arguments if there was a
672 * file name given to EnvironmentError. */
673 if (PyTuple_GET_SIZE(args)(((PyVarObject*)(args))->ob_size) == 2 && self->filename) {
674 args = PyTuple_New(3);
675 if (!args) return NULL((void*)0);
676
677 tmp = PyTuple_GET_ITEM(self->args, 0)(((PyTupleObject *)(self->args))->ob_item[0]);
678 Py_INCREF(tmp)( _Py_RefTotal++ , ((PyObject*)(tmp))->ob_refcnt++);
679 PyTuple_SET_ITEM(args, 0, tmp)(((PyTupleObject *)(args))->ob_item[0] = tmp);
680
681 tmp = PyTuple_GET_ITEM(self->args, 1)(((PyTupleObject *)(self->args))->ob_item[1]);
682 Py_INCREF(tmp)( _Py_RefTotal++ , ((PyObject*)(tmp))->ob_refcnt++);
683 PyTuple_SET_ITEM(args, 1, tmp)(((PyTupleObject *)(args))->ob_item[1] = tmp);
684
685 Py_INCREF(self->filename)( _Py_RefTotal++ , ((PyObject*)(self->filename))->ob_refcnt
++)
;
686 PyTuple_SET_ITEM(args, 2, self->filename)(((PyTupleObject *)(args))->ob_item[2] = self->filename
)
;
687 } else
688 Py_INCREF(args)( _Py_RefTotal++ , ((PyObject*)(args))->ob_refcnt++);
689
690 if (self->dict)
691 res = PyTuple_Pack(3, Py_TYPE(self)(((PyObject*)(self))->ob_type), args, self->dict);
692 else
693 res = PyTuple_Pack(2, Py_TYPE(self)(((PyObject*)(self))->ob_type), args);
694 Py_DECREF(args)do { if (_Py_RefTotal-- , --((PyObject*)(args))->ob_refcnt
!= 0) { if (((PyObject*)args)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 694, (PyObject *)(args)); } else _Py_Dealloc
((PyObject *)(args)); } while (0)
;
695 return res;
696}
697
698
699static PyMethodDef EnvironmentError_methods[] = {
700 {"__reduce__", (PyCFunction)EnvironmentError_reduce, METH_NOARGS0x0004},
701 {NULL((void*)0)}
702};
703
704ComplexExtendsException(PyExc_Exception, EnvironmentError,static PyTypeObject _PyExc_EnvironmentError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "EnvironmentError", sizeof(PyEnvironmentErrorObject
), 0, (destructor) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, (reprfunc)EnvironmentError_str, 0, 0, 0, ( 0 | (
1L<<18) | 0) | (1L<<10) | (1L<<14), "Base class for I/O related errors."
, (traverseproc) EnvironmentError_traverse, (inquiry) EnvironmentError_clear
, 0, 0, 0, 0, EnvironmentError_methods, EnvironmentError_members
, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_EnvironmentError = (PyObject *)&_PyExc_EnvironmentError
705 EnvironmentError, EnvironmentError_dealloc,static PyTypeObject _PyExc_EnvironmentError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "EnvironmentError", sizeof(PyEnvironmentErrorObject
), 0, (destructor) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, (reprfunc)EnvironmentError_str, 0, 0, 0, ( 0 | (
1L<<18) | 0) | (1L<<10) | (1L<<14), "Base class for I/O related errors."
, (traverseproc) EnvironmentError_traverse, (inquiry) EnvironmentError_clear
, 0, 0, 0, 0, EnvironmentError_methods, EnvironmentError_members
, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_EnvironmentError = (PyObject *)&_PyExc_EnvironmentError
706 EnvironmentError_methods, EnvironmentError_members,static PyTypeObject _PyExc_EnvironmentError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "EnvironmentError", sizeof(PyEnvironmentErrorObject
), 0, (destructor) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, (reprfunc)EnvironmentError_str, 0, 0, 0, ( 0 | (
1L<<18) | 0) | (1L<<10) | (1L<<14), "Base class for I/O related errors."
, (traverseproc) EnvironmentError_traverse, (inquiry) EnvironmentError_clear
, 0, 0, 0, 0, EnvironmentError_methods, EnvironmentError_members
, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_EnvironmentError = (PyObject *)&_PyExc_EnvironmentError
707 EnvironmentError_str,static PyTypeObject _PyExc_EnvironmentError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "EnvironmentError", sizeof(PyEnvironmentErrorObject
), 0, (destructor) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, (reprfunc)EnvironmentError_str, 0, 0, 0, ( 0 | (
1L<<18) | 0) | (1L<<10) | (1L<<14), "Base class for I/O related errors."
, (traverseproc) EnvironmentError_traverse, (inquiry) EnvironmentError_clear
, 0, 0, 0, 0, EnvironmentError_methods, EnvironmentError_members
, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_EnvironmentError = (PyObject *)&_PyExc_EnvironmentError
708 "Base class for I/O related errors.")static PyTypeObject _PyExc_EnvironmentError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "EnvironmentError", sizeof(PyEnvironmentErrorObject
), 0, (destructor) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, (reprfunc)EnvironmentError_str, 0, 0, 0, ( 0 | (
1L<<18) | 0) | (1L<<10) | (1L<<14), "Base class for I/O related errors."
, (traverseproc) EnvironmentError_traverse, (inquiry) EnvironmentError_clear
, 0, 0, 0, 0, EnvironmentError_methods, EnvironmentError_members
, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_EnvironmentError = (PyObject *)&_PyExc_EnvironmentError
;
709
710
711/*
712 * IOError extends EnvironmentError
713 */
714MiddlingExtendsException(PyExc_EnvironmentError, IOError,static PyTypeObject _PyExc_IOError = { { { 0, 0, 1, ((void*)0
) }, 0 }, "IOError", sizeof(PyEnvironmentErrorObject), 0, (destructor
) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "I/O operation failed.", (traverseproc) EnvironmentError_traverse
, (inquiry) EnvironmentError_clear, 0, 0, 0, 0, 0, 0, 0, &
_PyExc_EnvironmentError, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_IOError = (PyObject *)&_PyExc_IOError
715 EnvironmentError, "I/O operation failed.")static PyTypeObject _PyExc_IOError = { { { 0, 0, 1, ((void*)0
) }, 0 }, "IOError", sizeof(PyEnvironmentErrorObject), 0, (destructor
) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "I/O operation failed.", (traverseproc) EnvironmentError_traverse
, (inquiry) EnvironmentError_clear, 0, 0, 0, 0, 0, 0, 0, &
_PyExc_EnvironmentError, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_IOError = (PyObject *)&_PyExc_IOError
;
716
717
718/*
719 * OSError extends EnvironmentError
720 */
721MiddlingExtendsException(PyExc_EnvironmentError, OSError,static PyTypeObject _PyExc_OSError = { { { 0, 0, 1, ((void*)0
) }, 0 }, "OSError", sizeof(PyEnvironmentErrorObject), 0, (destructor
) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "OS system call failed.", (traverseproc) EnvironmentError_traverse
, (inquiry) EnvironmentError_clear, 0, 0, 0, 0, 0, 0, 0, &
_PyExc_EnvironmentError, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_OSError = (PyObject *)&_PyExc_OSError
722 EnvironmentError, "OS system call failed.")static PyTypeObject _PyExc_OSError = { { { 0, 0, 1, ((void*)0
) }, 0 }, "OSError", sizeof(PyEnvironmentErrorObject), 0, (destructor
) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "OS system call failed.", (traverseproc) EnvironmentError_traverse
, (inquiry) EnvironmentError_clear, 0, 0, 0, 0, 0, 0, 0, &
_PyExc_EnvironmentError, 0, 0, 0, __builtin_offsetof(PyEnvironmentErrorObject
, dict), (initproc) EnvironmentError_init, 0, BaseException_new
,}; PyObject *PyExc_OSError = (PyObject *)&_PyExc_OSError
;
723
724
725/*
726 * WindowsError extends OSError
727 */
728#ifdef MS_WINDOWS
729#include "errmap.h"
730
731static int
732WindowsError_clear(PyWindowsErrorObject *self)
733{
734 Py_CLEAR(self->myerrno)do { if (self->myerrno) { PyObject *_py_tmp = (PyObject *)
(self->myerrno); (self->myerrno) = ((void*)0); do { if (
_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0)
{ if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 734, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
735 Py_CLEAR(self->strerror)do { if (self->strerror) { PyObject *_py_tmp = (PyObject *
)(self->strerror); (self->strerror) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 735, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
736 Py_CLEAR(self->filename)do { if (self->filename) { PyObject *_py_tmp = (PyObject *
)(self->filename); (self->filename) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 736, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
737 Py_CLEAR(self->winerror)do { if (self->winerror) { PyObject *_py_tmp = (PyObject *
)(self->winerror); (self->winerror) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 737, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
738 return BaseException_clear((PyBaseExceptionObject *)self);
739}
740
741static void
742WindowsError_dealloc(PyWindowsErrorObject *self)
743{
744 _PyObject_GC_UNTRACK(self)do { PyGC_Head *g = ((PyGC_Head *)(self)-1); (__builtin_expect
(!(g->gc.gc_refs != (-2)), 0) ? __assert_rtn(__func__, "Objects/exceptions.c"
, 744, "g->gc.gc_refs != _PyGC_REFS_UNTRACKED") : (void)0)
; g->gc.gc_refs = (-2); g->gc.gc_prev->gc.gc_next = g
->gc.gc_next; g->gc.gc_next->gc.gc_prev = g->gc.gc_prev
; g->gc.gc_next = ((void*)0); } while (0);
;
745 WindowsError_clear(self);
746 Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self);
747}
748
749static int
750WindowsError_traverse(PyWindowsErrorObject *self, visitproc visit, void *arg)
751{
752 Py_VISIT(self->myerrno)do { if (self->myerrno) { int vret = visit((PyObject *)(self
->myerrno), arg); if (vret) return vret; } } while (0)
;
753 Py_VISIT(self->strerror)do { if (self->strerror) { int vret = visit((PyObject *)(self
->strerror), arg); if (vret) return vret; } } while (0)
;
754 Py_VISIT(self->filename)do { if (self->filename) { int vret = visit((PyObject *)(self
->filename), arg); if (vret) return vret; } } while (0)
;
755 Py_VISIT(self->winerror)do { if (self->winerror) { int vret = visit((PyObject *)(self
->winerror), arg); if (vret) return vret; } } while (0)
;
756 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
757}
758
759static int
760WindowsError_init(PyWindowsErrorObject *self, PyObject *args, PyObject *kwds)
761{
762 PyObject *o_errcode = NULL((void*)0);
763 long errcode;
764 long posix_errno;
765
766 if (EnvironmentError_init((PyEnvironmentErrorObject *)self, args, kwds)
767 == -1)
768 return -1;
769
770 if (self->myerrno == NULL((void*)0))
771 return 0;
772
773 /* Set errno to the POSIX errno, and winerror to the Win32
774 error code. */
775 errcode = PyLong_AsLong(self->myerrno);
776 if (errcode == -1 && PyErr_Occurred())
777 return -1;
778 posix_errno = winerror_to_errno(errcode);
779
780 Py_CLEAR(self->winerror)do { if (self->winerror) { PyObject *_py_tmp = (PyObject *
)(self->winerror); (self->winerror) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 780, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
781 self->winerror = self->myerrno;
782
783 o_errcode = PyLong_FromLong(posix_errno);
784 if (!o_errcode)
785 return -1;
786
787 self->myerrno = o_errcode;
788
789 return 0;
790}
791
792
793static PyObject *
794WindowsError_str(PyWindowsErrorObject *self)
795{
796 if (self->filename)
797 return PyUnicode_FromFormatPyUnicodeUCS2_FromFormat("[Error %S] %S: %R",
798 self->winerror ? self->winerror: Py_None(&_Py_NoneStruct),
799 self->strerror ? self->strerror: Py_None(&_Py_NoneStruct),
800 self->filename);
801 else if (self->winerror && self->strerror)
802 return PyUnicode_FromFormatPyUnicodeUCS2_FromFormat("[Error %S] %S",
803 self->winerror ? self->winerror: Py_None(&_Py_NoneStruct),
804 self->strerror ? self->strerror: Py_None(&_Py_NoneStruct));
805 else
806 return EnvironmentError_str((PyEnvironmentErrorObject *)self);
807}
808
809static PyMemberDef WindowsError_members[] = {
810 {"errno", T_OBJECT6, offsetof(PyWindowsErrorObject, myerrno)__builtin_offsetof(PyWindowsErrorObject, myerrno), 0,
811 PyDoc_STR("POSIX exception code")"POSIX exception code"},
812 {"strerror", T_OBJECT6, offsetof(PyWindowsErrorObject, strerror)__builtin_offsetof(PyWindowsErrorObject, strerror), 0,
813 PyDoc_STR("exception strerror")"exception strerror"},
814 {"filename", T_OBJECT6, offsetof(PyWindowsErrorObject, filename)__builtin_offsetof(PyWindowsErrorObject, filename), 0,
815 PyDoc_STR("exception filename")"exception filename"},
816 {"winerror", T_OBJECT6, offsetof(PyWindowsErrorObject, winerror)__builtin_offsetof(PyWindowsErrorObject, winerror), 0,
817 PyDoc_STR("Win32 exception code")"Win32 exception code"},
818 {NULL((void*)0)} /* Sentinel */
819};
820
821ComplexExtendsException(PyExc_OSError, WindowsError, WindowsError,static PyTypeObject _PyExc_WindowsError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "WindowsError", sizeof(PyWindowsErrorObject), 0,
(destructor) WindowsError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, (reprfunc)WindowsError_str, 0, 0, 0, ( 0 | (1L<<18
) | 0) | (1L<<10) | (1L<<14), "MS-Windows OS system call failed."
, (traverseproc) WindowsError_traverse, (inquiry) WindowsError_clear
, 0, 0, 0, 0, 0, WindowsError_members, 0, &_PyExc_OSError
, 0, 0, 0, __builtin_offsetof(PyWindowsErrorObject, dict), (initproc
) WindowsError_init, 0, BaseException_new,}; PyObject *PyExc_WindowsError
= (PyObject *)&_PyExc_WindowsError
822 WindowsError_dealloc, 0, WindowsError_members,static PyTypeObject _PyExc_WindowsError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "WindowsError", sizeof(PyWindowsErrorObject), 0,
(destructor) WindowsError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, (reprfunc)WindowsError_str, 0, 0, 0, ( 0 | (1L<<18
) | 0) | (1L<<10) | (1L<<14), "MS-Windows OS system call failed."
, (traverseproc) WindowsError_traverse, (inquiry) WindowsError_clear
, 0, 0, 0, 0, 0, WindowsError_members, 0, &_PyExc_OSError
, 0, 0, 0, __builtin_offsetof(PyWindowsErrorObject, dict), (initproc
) WindowsError_init, 0, BaseException_new,}; PyObject *PyExc_WindowsError
= (PyObject *)&_PyExc_WindowsError
823 WindowsError_str, "MS-Windows OS system call failed.")static PyTypeObject _PyExc_WindowsError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "WindowsError", sizeof(PyWindowsErrorObject), 0,
(destructor) WindowsError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, (reprfunc)WindowsError_str, 0, 0, 0, ( 0 | (1L<<18
) | 0) | (1L<<10) | (1L<<14), "MS-Windows OS system call failed."
, (traverseproc) WindowsError_traverse, (inquiry) WindowsError_clear
, 0, 0, 0, 0, 0, WindowsError_members, 0, &_PyExc_OSError
, 0, 0, 0, __builtin_offsetof(PyWindowsErrorObject, dict), (initproc
) WindowsError_init, 0, BaseException_new,}; PyObject *PyExc_WindowsError
= (PyObject *)&_PyExc_WindowsError
;
824
825#endif /* MS_WINDOWS */
826
827
828/*
829 * VMSError extends OSError (I think)
830 */
831#ifdef __VMS
832MiddlingExtendsException(PyExc_OSError, VMSError, EnvironmentError,static PyTypeObject _PyExc_VMSError = { { { 0, 0, 1, ((void*)
0) }, 0 }, "VMSError", sizeof(PyEnvironmentErrorObject), 0, (
destructor) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10)
| (1L<<14), "OpenVMS OS system call failed.", (traverseproc
) EnvironmentError_traverse, (inquiry) EnvironmentError_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_OSError, 0, 0, 0, __builtin_offsetof
(PyEnvironmentErrorObject, dict), (initproc) EnvironmentError_init
, 0, BaseException_new,}; PyObject *PyExc_VMSError = (PyObject
*)&_PyExc_VMSError
833 "OpenVMS OS system call failed.")static PyTypeObject _PyExc_VMSError = { { { 0, 0, 1, ((void*)
0) }, 0 }, "VMSError", sizeof(PyEnvironmentErrorObject), 0, (
destructor) EnvironmentError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10)
| (1L<<14), "OpenVMS OS system call failed.", (traverseproc
) EnvironmentError_traverse, (inquiry) EnvironmentError_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_OSError, 0, 0, 0, __builtin_offsetof
(PyEnvironmentErrorObject, dict), (initproc) EnvironmentError_init
, 0, BaseException_new,}; PyObject *PyExc_VMSError = (PyObject
*)&_PyExc_VMSError
;
834#endif
835
836
837/*
838 * EOFError extends Exception
839 */
840SimpleExtendsException(PyExc_Exception, EOFError,static PyTypeObject _PyExc_EOFError = { { { 0, 0, 1, ((void*)
0) }, 0 }, "EOFError", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Read beyond end of file.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_EOFError = (PyObject *)&_PyExc_EOFError
841 "Read beyond end of file.")static PyTypeObject _PyExc_EOFError = { { { 0, 0, 1, ((void*)
0) }, 0 }, "EOFError", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Read beyond end of file.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_EOFError = (PyObject *)&_PyExc_EOFError
;
842
843
844/*
845 * RuntimeError extends Exception
846 */
847SimpleExtendsException(PyExc_Exception, RuntimeError,static PyTypeObject _PyExc_RuntimeError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "RuntimeError", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Unspecified run-time error.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_RuntimeError = (PyObject
*)&_PyExc_RuntimeError
848 "Unspecified run-time error.")static PyTypeObject _PyExc_RuntimeError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "RuntimeError", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Unspecified run-time error.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_RuntimeError = (PyObject
*)&_PyExc_RuntimeError
;
849
850
851/*
852 * NotImplementedError extends RuntimeError
853 */
854SimpleExtendsException(PyExc_RuntimeError, NotImplementedError,static PyTypeObject _PyExc_NotImplementedError = { { { 0, 0, 1
, ((void*)0) }, 0 }, "NotImplementedError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Method or function hasn't been implemented yet."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_RuntimeError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_NotImplementedError = (
PyObject *)&_PyExc_NotImplementedError
855 "Method or function hasn't been implemented yet.")static PyTypeObject _PyExc_NotImplementedError = { { { 0, 0, 1
, ((void*)0) }, 0 }, "NotImplementedError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Method or function hasn't been implemented yet."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_RuntimeError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_NotImplementedError = (
PyObject *)&_PyExc_NotImplementedError
;
856
857/*
858 * NameError extends Exception
859 */
860SimpleExtendsException(PyExc_Exception, NameError,static PyTypeObject _PyExc_NameError = { { { 0, 0, 1, ((void*
)0) }, 0 }, "NameError", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Name not found globally.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_NameError = (PyObject *)&_PyExc_NameError
861 "Name not found globally.")static PyTypeObject _PyExc_NameError = { { { 0, 0, 1, ((void*
)0) }, 0 }, "NameError", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Name not found globally.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_NameError = (PyObject *)&_PyExc_NameError
;
862
863/*
864 * UnboundLocalError extends NameError
865 */
866SimpleExtendsException(PyExc_NameError, UnboundLocalError,static PyTypeObject _PyExc_UnboundLocalError = { { { 0, 0, 1,
((void*)0) }, 0 }, "UnboundLocalError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Local name referenced but not bound to a value."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_NameError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_UnboundLocalError = (PyObject
*)&_PyExc_UnboundLocalError
867 "Local name referenced but not bound to a value.")static PyTypeObject _PyExc_UnboundLocalError = { { { 0, 0, 1,
((void*)0) }, 0 }, "UnboundLocalError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Local name referenced but not bound to a value."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_NameError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_UnboundLocalError = (PyObject
*)&_PyExc_UnboundLocalError
;
868
869/*
870 * AttributeError extends Exception
871 */
872SimpleExtendsException(PyExc_Exception, AttributeError,static PyTypeObject _PyExc_AttributeError = { { { 0, 0, 1, ((
void*)0) }, 0 }, "AttributeError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Attribute not found.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_AttributeError = (PyObject *)&_PyExc_AttributeError
873 "Attribute not found.")static PyTypeObject _PyExc_AttributeError = { { { 0, 0, 1, ((
void*)0) }, 0 }, "AttributeError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Attribute not found.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_AttributeError = (PyObject *)&_PyExc_AttributeError
;
874
875
876/*
877 * SyntaxError extends Exception
878 */
879
880static int
881SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds)
882{
883 PyObject *info = NULL((void*)0);
884 Py_ssize_t lenargs = PyTuple_GET_SIZE(args)(((PyVarObject*)(args))->ob_size);
885
886 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
887 return -1;
888
889 if (lenargs >= 1) {
890 Py_CLEAR(self->msg)do { if (self->msg) { PyObject *_py_tmp = (PyObject *)(self
->msg); (self->msg) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 890, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
891 self->msg = PyTuple_GET_ITEM(args, 0)(((PyTupleObject *)(args))->ob_item[0]);
892 Py_INCREF(self->msg)( _Py_RefTotal++ , ((PyObject*)(self->msg))->ob_refcnt++
)
;
893 }
894 if (lenargs == 2) {
895 info = PyTuple_GET_ITEM(args, 1)(((PyTupleObject *)(args))->ob_item[1]);
896 info = PySequence_Tuple(info);
897 if (!info) return -1;
898
899 if (PyTuple_GET_SIZE(info)(((PyVarObject*)(info))->ob_size) != 4) {
900 /* not a very good error message, but it's what Python 2.4 gives */
901 PyErr_SetString(PyExc_IndexError, "tuple index out of range");
902 Py_DECREF(info)do { if (_Py_RefTotal-- , --((PyObject*)(info))->ob_refcnt
!= 0) { if (((PyObject*)info)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 902, (PyObject *)(info)); } else _Py_Dealloc
((PyObject *)(info)); } while (0)
;
903 return -1;
904 }
905
906 Py_CLEAR(self->filename)do { if (self->filename) { PyObject *_py_tmp = (PyObject *
)(self->filename); (self->filename) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 906, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
907 self->filename = PyTuple_GET_ITEM(info, 0)(((PyTupleObject *)(info))->ob_item[0]);
908 Py_INCREF(self->filename)( _Py_RefTotal++ , ((PyObject*)(self->filename))->ob_refcnt
++)
;
909
910 Py_CLEAR(self->lineno)do { if (self->lineno) { PyObject *_py_tmp = (PyObject *)(
self->lineno); (self->lineno) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 910, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
911 self->lineno = PyTuple_GET_ITEM(info, 1)(((PyTupleObject *)(info))->ob_item[1]);
912 Py_INCREF(self->lineno)( _Py_RefTotal++ , ((PyObject*)(self->lineno))->ob_refcnt
++)
;
913
914 Py_CLEAR(self->offset)do { if (self->offset) { PyObject *_py_tmp = (PyObject *)(
self->offset); (self->offset) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 914, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
915 self->offset = PyTuple_GET_ITEM(info, 2)(((PyTupleObject *)(info))->ob_item[2]);
916 Py_INCREF(self->offset)( _Py_RefTotal++ , ((PyObject*)(self->offset))->ob_refcnt
++)
;
917
918 Py_CLEAR(self->text)do { if (self->text) { PyObject *_py_tmp = (PyObject *)(self
->text); (self->text) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 918, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
919 self->text = PyTuple_GET_ITEM(info, 3)(((PyTupleObject *)(info))->ob_item[3]);
920 Py_INCREF(self->text)( _Py_RefTotal++ , ((PyObject*)(self->text))->ob_refcnt
++)
;
921
922 Py_DECREF(info)do { if (_Py_RefTotal-- , --((PyObject*)(info))->ob_refcnt
!= 0) { if (((PyObject*)info)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 922, (PyObject *)(info)); } else _Py_Dealloc
((PyObject *)(info)); } while (0)
;
923 }
924 return 0;
925}
926
927static int
928SyntaxError_clear(PySyntaxErrorObject *self)
929{
930 Py_CLEAR(self->msg)do { if (self->msg) { PyObject *_py_tmp = (PyObject *)(self
->msg); (self->msg) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 930, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
931 Py_CLEAR(self->filename)do { if (self->filename) { PyObject *_py_tmp = (PyObject *
)(self->filename); (self->filename) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 931, (PyObject *)(_py_tmp)); } else _Py_Dealloc
((PyObject *)(_py_tmp)); } while (0); } } while (0)
;
932 Py_CLEAR(self->lineno)do { if (self->lineno) { PyObject *_py_tmp = (PyObject *)(
self->lineno); (self->lineno) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 932, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
933 Py_CLEAR(self->offset)do { if (self->offset) { PyObject *_py_tmp = (PyObject *)(
self->offset); (self->offset) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 933, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
934 Py_CLEAR(self->text)do { if (self->text) { PyObject *_py_tmp = (PyObject *)(self
->text); (self->text) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 934, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
935 Py_CLEAR(self->print_file_and_line)do { if (self->print_file_and_line) { PyObject *_py_tmp = (
PyObject *)(self->print_file_and_line); (self->print_file_and_line
) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp
))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt
< 0) _Py_NegativeRefcount("Objects/exceptions.c", 935, (PyObject
*)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while
(0); } } while (0)
;
936 return BaseException_clear((PyBaseExceptionObject *)self);
937}
938
939static void
940SyntaxError_dealloc(PySyntaxErrorObject *self)
941{
942 _PyObject_GC_UNTRACK(self)do { PyGC_Head *g = ((PyGC_Head *)(self)-1); (__builtin_expect
(!(g->gc.gc_refs != (-2)), 0) ? __assert_rtn(__func__, "Objects/exceptions.c"
, 942, "g->gc.gc_refs != _PyGC_REFS_UNTRACKED") : (void)0)
; g->gc.gc_refs = (-2); g->gc.gc_prev->gc.gc_next = g
->gc.gc_next; g->gc.gc_next->gc.gc_prev = g->gc.gc_prev
; g->gc.gc_next = ((void*)0); } while (0);
;
943 SyntaxError_clear(self);
944 Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self);
945}
946
947static int
948SyntaxError_traverse(PySyntaxErrorObject *self, visitproc visit, void *arg)
949{
950 Py_VISIT(self->msg)do { if (self->msg) { int vret = visit((PyObject *)(self->
msg), arg); if (vret) return vret; } } while (0)
;
951 Py_VISIT(self->filename)do { if (self->filename) { int vret = visit((PyObject *)(self
->filename), arg); if (vret) return vret; } } while (0)
;
952 Py_VISIT(self->lineno)do { if (self->lineno) { int vret = visit((PyObject *)(self
->lineno), arg); if (vret) return vret; } } while (0)
;
953 Py_VISIT(self->offset)do { if (self->offset) { int vret = visit((PyObject *)(self
->offset), arg); if (vret) return vret; } } while (0)
;
954 Py_VISIT(self->text)do { if (self->text) { int vret = visit((PyObject *)(self->
text), arg); if (vret) return vret; } } while (0)
;
955 Py_VISIT(self->print_file_and_line)do { if (self->print_file_and_line) { int vret = visit((PyObject
*)(self->print_file_and_line), arg); if (vret) return vret
; } } while (0)
;
956 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
957}
958
959/* This is called "my_basename" instead of just "basename" to avoid name
960 conflicts with glibc; basename is already prototyped if _GNU_SOURCE is
961 defined, and Python does define that. */
962static PyObject*
963my_basename(PyObject *name)
964{
965 Py_UNICODE *unicode;
966 Py_ssize_t i, size, offset;
967
968 unicode = PyUnicode_AS_UNICODE(name)((__builtin_expect(!(((((((PyObject*)(name))->ob_type))->
tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__
, "Objects/exceptions.c", 968, "PyUnicode_Check(name)") : (void
)0),(((PyUnicodeObject *)(name))->str))
;
969 size = PyUnicode_GET_SIZE(name)((__builtin_expect(!(((((((PyObject*)(name))->ob_type))->
tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__
, "Objects/exceptions.c", 969, "PyUnicode_Check(name)") : (void
)0),(((PyUnicodeObject *)(name))->length))
;
970 offset = 0;
971 for(i=0; i < size; i++) {
972 if (unicode[i] == SEPL'/')
973 offset = i + 1;
974 }
975 if (offset != 0) {
976 return PyUnicode_FromUnicodePyUnicodeUCS2_FromUnicode(
977 PyUnicode_AS_UNICODE(name)((__builtin_expect(!(((((((PyObject*)(name))->ob_type))->
tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__
, "Objects/exceptions.c", 977, "PyUnicode_Check(name)") : (void
)0),(((PyUnicodeObject *)(name))->str))
+ offset,
978 size - offset);
979 } else {
980 Py_INCREF(name)( _Py_RefTotal++ , ((PyObject*)(name))->ob_refcnt++);
981 return name;
982 }
983}
984
985
986static PyObject *
987SyntaxError_str(PySyntaxErrorObject *self)
988{
989 int have_lineno = 0;
990 PyObject *filename;
991 PyObject *result;
992 /* Below, we always ignore overflow errors, just printing -1.
993 Still, we cannot allow an OverflowError to be raised, so
994 we need to call PyLong_AsLongAndOverflow. */
995 int overflow;
996
997 /* XXX -- do all the additional formatting with filename and
998 lineno here */
999
1000 if (self->filename && PyUnicode_Check(self->filename)((((((PyObject*)(self->filename))->ob_type))->tp_flags
& ((1L<<28))) != 0)
) {
1001 filename = my_basename(self->filename);
1002 if (filename == NULL((void*)0))
1003 return NULL((void*)0);
1004 } else {
1005 filename = NULL((void*)0);
1006 }
1007 have_lineno = (self->lineno != NULL((void*)0)) && PyLong_CheckExact(self->lineno)((((PyObject*)(self->lineno))->ob_type) == &PyLong_Type
)
;
1008
1009 if (!filename && !have_lineno)
1010 return PyObject_Str(self->msg ? self->msg : Py_None(&_Py_NoneStruct));
1011
1012 if (filename && have_lineno)
1013 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat("%S (%U, line %ld)",
1014 self->msg ? self->msg : Py_None(&_Py_NoneStruct),
1015 filename,
1016 PyLong_AsLongAndOverflow(self->lineno, &overflow));
1017 else if (filename)
1018 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat("%S (%U)",
1019 self->msg ? self->msg : Py_None(&_Py_NoneStruct),
1020 filename);
1021 else /* only have_lineno */
1022 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat("%S (line %ld)",
1023 self->msg ? self->msg : Py_None(&_Py_NoneStruct),
1024 PyLong_AsLongAndOverflow(self->lineno, &overflow));
1025 Py_XDECREF(filename)do { if ((filename) == ((void*)0)) ; else do { if (_Py_RefTotal
-- , --((PyObject*)(filename))->ob_refcnt != 0) { if (((PyObject
*)filename)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1025, (PyObject *)(filename)); } else _Py_Dealloc((PyObject
*)(filename)); } while (0); } while (0)
;
1026 return result;
1027}
1028
1029static PyMemberDef SyntaxError_members[] = {
1030 {"msg", T_OBJECT6, offsetof(PySyntaxErrorObject, msg)__builtin_offsetof(PySyntaxErrorObject, msg), 0,
1031 PyDoc_STR("exception msg")"exception msg"},
1032 {"filename", T_OBJECT6, offsetof(PySyntaxErrorObject, filename)__builtin_offsetof(PySyntaxErrorObject, filename), 0,
1033 PyDoc_STR("exception filename")"exception filename"},
1034 {"lineno", T_OBJECT6, offsetof(PySyntaxErrorObject, lineno)__builtin_offsetof(PySyntaxErrorObject, lineno), 0,
1035 PyDoc_STR("exception lineno")"exception lineno"},
1036 {"offset", T_OBJECT6, offsetof(PySyntaxErrorObject, offset)__builtin_offsetof(PySyntaxErrorObject, offset), 0,
1037 PyDoc_STR("exception offset")"exception offset"},
1038 {"text", T_OBJECT6, offsetof(PySyntaxErrorObject, text)__builtin_offsetof(PySyntaxErrorObject, text), 0,
1039 PyDoc_STR("exception text")"exception text"},
1040 {"print_file_and_line", T_OBJECT6,
1041 offsetof(PySyntaxErrorObject, print_file_and_line)__builtin_offsetof(PySyntaxErrorObject, print_file_and_line), 0,
1042 PyDoc_STR("exception print_file_and_line")"exception print_file_and_line"},
1043 {NULL((void*)0)} /* Sentinel */
1044};
1045
1046ComplexExtendsException(PyExc_Exception, SyntaxError, SyntaxError,static PyTypeObject _PyExc_SyntaxError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SyntaxError", sizeof(PySyntaxErrorObject), 0, (
destructor) SyntaxError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, (reprfunc)SyntaxError_str, 0, 0, 0, ( 0 | (1L<<18) | 0
) | (1L<<10) | (1L<<14), "Invalid syntax.", (traverseproc
) SyntaxError_traverse, (inquiry) SyntaxError_clear, 0, 0, 0,
0, 0, SyntaxError_members, 0, &_PyExc_Exception, 0, 0, 0
, __builtin_offsetof(PySyntaxErrorObject, dict), (initproc) SyntaxError_init
, 0, BaseException_new,}; PyObject *PyExc_SyntaxError = (PyObject
*)&_PyExc_SyntaxError
1047 SyntaxError_dealloc, 0, SyntaxError_members,static PyTypeObject _PyExc_SyntaxError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SyntaxError", sizeof(PySyntaxErrorObject), 0, (
destructor) SyntaxError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, (reprfunc)SyntaxError_str, 0, 0, 0, ( 0 | (1L<<18) | 0
) | (1L<<10) | (1L<<14), "Invalid syntax.", (traverseproc
) SyntaxError_traverse, (inquiry) SyntaxError_clear, 0, 0, 0,
0, 0, SyntaxError_members, 0, &_PyExc_Exception, 0, 0, 0
, __builtin_offsetof(PySyntaxErrorObject, dict), (initproc) SyntaxError_init
, 0, BaseException_new,}; PyObject *PyExc_SyntaxError = (PyObject
*)&_PyExc_SyntaxError
1048 SyntaxError_str, "Invalid syntax.")static PyTypeObject _PyExc_SyntaxError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SyntaxError", sizeof(PySyntaxErrorObject), 0, (
destructor) SyntaxError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, (reprfunc)SyntaxError_str, 0, 0, 0, ( 0 | (1L<<18) | 0
) | (1L<<10) | (1L<<14), "Invalid syntax.", (traverseproc
) SyntaxError_traverse, (inquiry) SyntaxError_clear, 0, 0, 0,
0, 0, SyntaxError_members, 0, &_PyExc_Exception, 0, 0, 0
, __builtin_offsetof(PySyntaxErrorObject, dict), (initproc) SyntaxError_init
, 0, BaseException_new,}; PyObject *PyExc_SyntaxError = (PyObject
*)&_PyExc_SyntaxError
;
1049
1050
1051/*
1052 * IndentationError extends SyntaxError
1053 */
1054MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError,static PyTypeObject _PyExc_IndentationError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "IndentationError", sizeof(PySyntaxErrorObject
), 0, (destructor) SyntaxError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10
) | (1L<<14), "Improper indentation.", (traverseproc) SyntaxError_traverse
, (inquiry) SyntaxError_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_SyntaxError
, 0, 0, 0, __builtin_offsetof(PySyntaxErrorObject, dict), (initproc
) SyntaxError_init, 0, BaseException_new,}; PyObject *PyExc_IndentationError
= (PyObject *)&_PyExc_IndentationError
1055 "Improper indentation.")static PyTypeObject _PyExc_IndentationError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "IndentationError", sizeof(PySyntaxErrorObject
), 0, (destructor) SyntaxError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10
) | (1L<<14), "Improper indentation.", (traverseproc) SyntaxError_traverse
, (inquiry) SyntaxError_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_SyntaxError
, 0, 0, 0, __builtin_offsetof(PySyntaxErrorObject, dict), (initproc
) SyntaxError_init, 0, BaseException_new,}; PyObject *PyExc_IndentationError
= (PyObject *)&_PyExc_IndentationError
;
1056
1057
1058/*
1059 * TabError extends IndentationError
1060 */
1061MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError,static PyTypeObject _PyExc_TabError = { { { 0, 0, 1, ((void*)
0) }, 0 }, "TabError", sizeof(PySyntaxErrorObject), 0, (destructor
) SyntaxError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<14
), "Improper mixture of spaces and tabs.", (traverseproc) SyntaxError_traverse
, (inquiry) SyntaxError_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_IndentationError
, 0, 0, 0, __builtin_offsetof(PySyntaxErrorObject, dict), (initproc
) SyntaxError_init, 0, BaseException_new,}; PyObject *PyExc_TabError
= (PyObject *)&_PyExc_TabError
1062 "Improper mixture of spaces and tabs.")static PyTypeObject _PyExc_TabError = { { { 0, 0, 1, ((void*)
0) }, 0 }, "TabError", sizeof(PySyntaxErrorObject), 0, (destructor
) SyntaxError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<14
), "Improper mixture of spaces and tabs.", (traverseproc) SyntaxError_traverse
, (inquiry) SyntaxError_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_IndentationError
, 0, 0, 0, __builtin_offsetof(PySyntaxErrorObject, dict), (initproc
) SyntaxError_init, 0, BaseException_new,}; PyObject *PyExc_TabError
= (PyObject *)&_PyExc_TabError
;
1063
1064
1065/*
1066 * LookupError extends Exception
1067 */
1068SimpleExtendsException(PyExc_Exception, LookupError,static PyTypeObject _PyExc_LookupError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "LookupError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for lookup errors.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_LookupError = (PyObject
*)&_PyExc_LookupError
1069 "Base class for lookup errors.")static PyTypeObject _PyExc_LookupError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "LookupError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for lookup errors.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_LookupError = (PyObject
*)&_PyExc_LookupError
;
1070
1071
1072/*
1073 * IndexError extends LookupError
1074 */
1075SimpleExtendsException(PyExc_LookupError, IndexError,static PyTypeObject _PyExc_IndexError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "IndexError", sizeof(PyBaseExceptionObject), 0, (
destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L
<<14), "Sequence index out of range.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_LookupError
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_IndexError = (PyObject *)&_PyExc_IndexError
1076 "Sequence index out of range.")static PyTypeObject _PyExc_IndexError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "IndexError", sizeof(PyBaseExceptionObject), 0, (
destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L
<<14), "Sequence index out of range.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_LookupError
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_IndexError = (PyObject *)&_PyExc_IndexError
;
1077
1078
1079/*
1080 * KeyError extends LookupError
1081 */
1082static PyObject *
1083KeyError_str(PyBaseExceptionObject *self)
1084{
1085 /* If args is a tuple of exactly one item, apply repr to args[0].
1086 This is done so that e.g. the exception raised by {}[''] prints
1087 KeyError: ''
1088 rather than the confusing
1089 KeyError
1090 alone. The downside is that if KeyError is raised with an explanatory
1091 string, that string will be displayed in quotes. Too bad.
1092 If args is anything else, use the default BaseException__str__().
1093 */
1094 if (PyTuple_GET_SIZE(self->args)(((PyVarObject*)(self->args))->ob_size) == 1) {
1095 return PyObject_Repr(PyTuple_GET_ITEM(self->args, 0)(((PyTupleObject *)(self->args))->ob_item[0]));
1096 }
1097 return BaseException_str(self);
1098}
1099
1100ComplexExtendsException(PyExc_LookupError, KeyError, BaseException,static PyTypeObject _PyExc_KeyError = { { { 0, 0, 1, ((void*)
0) }, 0 }, "KeyError", sizeof(PyBaseExceptionObject), 0, (destructor
) BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc
)KeyError_str, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Mapping key not found.", (traverseproc
) BaseException_traverse, (inquiry) BaseException_clear, 0, 0
, 0, 0, 0, 0, 0, &_PyExc_LookupError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc) BaseException_init,
0, BaseException_new,}; PyObject *PyExc_KeyError = (PyObject
*)&_PyExc_KeyError
1101 0, 0, 0, KeyError_str, "Mapping key not found.")static PyTypeObject _PyExc_KeyError = { { { 0, 0, 1, ((void*)
0) }, 0 }, "KeyError", sizeof(PyBaseExceptionObject), 0, (destructor
) BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc
)KeyError_str, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Mapping key not found.", (traverseproc
) BaseException_traverse, (inquiry) BaseException_clear, 0, 0
, 0, 0, 0, 0, 0, &_PyExc_LookupError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc) BaseException_init,
0, BaseException_new,}; PyObject *PyExc_KeyError = (PyObject
*)&_PyExc_KeyError
;
1102
1103
1104/*
1105 * ValueError extends Exception
1106 */
1107SimpleExtendsException(PyExc_Exception, ValueError,static PyTypeObject _PyExc_ValueError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "ValueError", sizeof(PyBaseExceptionObject), 0, (
destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L
<<14), "Inappropriate argument value (of correct type)."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ValueError = (PyObject
*)&_PyExc_ValueError
1108 "Inappropriate argument value (of correct type).")static PyTypeObject _PyExc_ValueError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "ValueError", sizeof(PyBaseExceptionObject), 0, (
destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L
<<14), "Inappropriate argument value (of correct type)."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ValueError = (PyObject
*)&_PyExc_ValueError
;
1109
1110/*
1111 * UnicodeError extends ValueError
1112 */
1113
1114SimpleExtendsException(PyExc_ValueError, UnicodeError,static PyTypeObject _PyExc_UnicodeError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "UnicodeError", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Unicode related error.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_ValueError
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_UnicodeError = (PyObject *)&_PyExc_UnicodeError
1115 "Unicode related error.")static PyTypeObject _PyExc_UnicodeError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "UnicodeError", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Unicode related error.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_ValueError
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_UnicodeError = (PyObject *)&_PyExc_UnicodeError
;
1116
1117static PyObject *
1118get_string(PyObject *attr, const char *name)
1119{
1120 if (!attr) {
1121 PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name);
1122 return NULL((void*)0);
1123 }
1124
1125 if (!PyBytes_Check(attr)((((((PyObject*)(attr))->ob_type))->tp_flags & ((1L
<<27))) != 0)
) {
1126 PyErr_Format(PyExc_TypeError, "%.200s attribute must be bytes", name);
1127 return NULL((void*)0);
1128 }
1129 Py_INCREF(attr)( _Py_RefTotal++ , ((PyObject*)(attr))->ob_refcnt++);
1130 return attr;
1131}
1132
1133static PyObject *
1134get_unicode(PyObject *attr, const char *name)
1135{
1136 if (!attr) {
1137 PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name);
1138 return NULL((void*)0);
1139 }
1140
1141 if (!PyUnicode_Check(attr)((((((PyObject*)(attr))->ob_type))->tp_flags & ((1L
<<28))) != 0)
) {
1142 PyErr_Format(PyExc_TypeError,
1143 "%.200s attribute must be unicode", name);
1144 return NULL((void*)0);
1145 }
1146 Py_INCREF(attr)( _Py_RefTotal++ , ((PyObject*)(attr))->ob_refcnt++);
1147 return attr;
1148}
1149
1150static int
1151set_unicodefromstring(PyObject **attr, const char *value)
1152{
1153 PyObject *obj = PyUnicode_FromStringPyUnicodeUCS2_FromString(value);
1154 if (!obj)
1155 return -1;
1156 Py_CLEAR(*attr)do { if (*attr) { PyObject *_py_tmp = (PyObject *)(*attr); (*
attr) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(
_py_tmp))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->
ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1156, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1157 *attr = obj;
1158 return 0;
1159}
1160
1161PyObject *
1162PyUnicodeEncodeError_GetEncoding(PyObject *exc)
1163{
1164 return get_unicode(((PyUnicodeErrorObject *)exc)->encoding, "encoding");
1165}
1166
1167PyObject *
1168PyUnicodeDecodeError_GetEncoding(PyObject *exc)
1169{
1170 return get_unicode(((PyUnicodeErrorObject *)exc)->encoding, "encoding");
1171}
1172
1173PyObject *
1174PyUnicodeEncodeError_GetObject(PyObject *exc)
1175{
1176 return get_unicode(((PyUnicodeErrorObject *)exc)->object, "object");
1177}
1178
1179PyObject *
1180PyUnicodeDecodeError_GetObject(PyObject *exc)
1181{
1182 return get_string(((PyUnicodeErrorObject *)exc)->object, "object");
1183}
1184
1185PyObject *
1186PyUnicodeTranslateError_GetObject(PyObject *exc)
1187{
1188 return get_unicode(((PyUnicodeErrorObject *)exc)->object, "object");
1189}
1190
1191int
1192PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
1193{
1194 Py_ssize_t size;
1195 PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object,
1196 "object");
1197 if (!obj)
1198 return -1;
1199 *start = ((PyUnicodeErrorObject *)exc)->start;
1200 size = PyUnicode_GET_SIZE(obj)((__builtin_expect(!(((((((PyObject*)(obj))->ob_type))->
tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__
, "Objects/exceptions.c", 1200, "PyUnicode_Check(obj)") : (void
)0),(((PyUnicodeObject *)(obj))->length))
;
1201 if (*start<0)
1202 *start = 0; /*XXX check for values <0*/
1203 if (*start>=size)
1204 *start = size-1;
1205 Py_DECREF(obj)do { if (_Py_RefTotal-- , --((PyObject*)(obj))->ob_refcnt !=
0) { if (((PyObject*)obj)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1205, (PyObject *)(obj)); } else _Py_Dealloc
((PyObject *)(obj)); } while (0)
;
1206 return 0;
1207}
1208
1209
1210int
1211PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
1212{
1213 Py_ssize_t size;
1214 PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object");
1215 if (!obj)
1216 return -1;
1217 size = PyBytes_GET_SIZE(obj)((__builtin_expect(!(((((((PyObject*)(obj))->ob_type))->
tp_flags & ((1L<<27))) != 0)), 0) ? __assert_rtn(__func__
, "Objects/exceptions.c", 1217, "PyBytes_Check(obj)") : (void
)0),(((PyVarObject*)(obj))->ob_size))
;
1218 *start = ((PyUnicodeErrorObject *)exc)->start;
1219 if (*start<0)
1220 *start = 0;
1221 if (*start>=size)
1222 *start = size-1;
1223 Py_DECREF(obj)do { if (_Py_RefTotal-- , --((PyObject*)(obj))->ob_refcnt !=
0) { if (((PyObject*)obj)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1223, (PyObject *)(obj)); } else _Py_Dealloc
((PyObject *)(obj)); } while (0)
;
1224 return 0;
1225}
1226
1227
1228int
1229PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start)
1230{
1231 return PyUnicodeEncodeError_GetStart(exc, start);
1232}
1233
1234
1235int
1236PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start)
1237{
1238 ((PyUnicodeErrorObject *)exc)->start = start;
1239 return 0;
1240}
1241
1242
1243int
1244PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
1245{
1246 ((PyUnicodeErrorObject *)exc)->start = start;
1247 return 0;
1248}
1249
1250
1251int
1252PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start)
1253{
1254 ((PyUnicodeErrorObject *)exc)->start = start;
1255 return 0;
1256}
1257
1258
1259int
1260PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
1261{
1262 Py_ssize_t size;
1263 PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object,
1264 "object");
1265 if (!obj)
1266 return -1;
1267 *end = ((PyUnicodeErrorObject *)exc)->end;
1268 size = PyUnicode_GET_SIZE(obj)((__builtin_expect(!(((((((PyObject*)(obj))->ob_type))->
tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__
, "Objects/exceptions.c", 1268, "PyUnicode_Check(obj)") : (void
)0),(((PyUnicodeObject *)(obj))->length))
;
1269 if (*end<1)
1270 *end = 1;
1271 if (*end>size)
1272 *end = size;
1273 Py_DECREF(obj)do { if (_Py_RefTotal-- , --((PyObject*)(obj))->ob_refcnt !=
0) { if (((PyObject*)obj)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1273, (PyObject *)(obj)); } else _Py_Dealloc
((PyObject *)(obj)); } while (0)
;
1274 return 0;
1275}
1276
1277
1278int
1279PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
1280{
1281 Py_ssize_t size;
1282 PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object");
1283 if (!obj)
1284 return -1;
1285 size = PyBytes_GET_SIZE(obj)((__builtin_expect(!(((((((PyObject*)(obj))->ob_type))->
tp_flags & ((1L<<27))) != 0)), 0) ? __assert_rtn(__func__
, "Objects/exceptions.c", 1285, "PyBytes_Check(obj)") : (void
)0),(((PyVarObject*)(obj))->ob_size))
;
1286 *end = ((PyUnicodeErrorObject *)exc)->end;
1287 if (*end<1)
1288 *end = 1;
1289 if (*end>size)
1290 *end = size;
1291 Py_DECREF(obj)do { if (_Py_RefTotal-- , --((PyObject*)(obj))->ob_refcnt !=
0) { if (((PyObject*)obj)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1291, (PyObject *)(obj)); } else _Py_Dealloc
((PyObject *)(obj)); } while (0)
;
1292 return 0;
1293}
1294
1295
1296int
1297PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *start)
1298{
1299 return PyUnicodeEncodeError_GetEnd(exc, start);
1300}
1301
1302
1303int
1304PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end)
1305{
1306 ((PyUnicodeErrorObject *)exc)->end = end;
1307 return 0;
1308}
1309
1310
1311int
1312PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
1313{
1314 ((PyUnicodeErrorObject *)exc)->end = end;
1315 return 0;
1316}
1317
1318
1319int
1320PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end)
1321{
1322 ((PyUnicodeErrorObject *)exc)->end = end;
1323 return 0;
1324}
1325
1326PyObject *
1327PyUnicodeEncodeError_GetReason(PyObject *exc)
1328{
1329 return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason");
1330}
1331
1332
1333PyObject *
1334PyUnicodeDecodeError_GetReason(PyObject *exc)
1335{
1336 return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason");
1337}
1338
1339
1340PyObject *
1341PyUnicodeTranslateError_GetReason(PyObject *exc)
1342{
1343 return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason");
1344}
1345
1346
1347int
1348PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason)
1349{
1350 return set_unicodefromstring(&((PyUnicodeErrorObject *)exc)->reason,
1351 reason);
1352}
1353
1354
1355int
1356PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason)
1357{
1358 return set_unicodefromstring(&((PyUnicodeErrorObject *)exc)->reason,
1359 reason);
1360}
1361
1362
1363int
1364PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason)
1365{
1366 return set_unicodefromstring(&((PyUnicodeErrorObject *)exc)->reason,
1367 reason);
1368}
1369
1370
1371static int
1372UnicodeError_clear(PyUnicodeErrorObject *self)
1373{
1374 Py_CLEAR(self->encoding)do { if (self->encoding) { PyObject *_py_tmp = (PyObject *
)(self->encoding); (self->encoding) = ((void*)0); do { if
(_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0
) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1374, (PyObject *)(_py_tmp)); } else
_Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (
0)
;
1375 Py_CLEAR(self->object)do { if (self->object) { PyObject *_py_tmp = (PyObject *)(
self->object); (self->object) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1375, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1376 Py_CLEAR(self->reason)do { if (self->reason) { PyObject *_py_tmp = (PyObject *)(
self->reason); (self->reason) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1376, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1377 return BaseException_clear((PyBaseExceptionObject *)self);
1378}
1379
1380static void
1381UnicodeError_dealloc(PyUnicodeErrorObject *self)
1382{
1383 _PyObject_GC_UNTRACK(self)do { PyGC_Head *g = ((PyGC_Head *)(self)-1); (__builtin_expect
(!(g->gc.gc_refs != (-2)), 0) ? __assert_rtn(__func__, "Objects/exceptions.c"
, 1383, "g->gc.gc_refs != _PyGC_REFS_UNTRACKED") : (void)0
); g->gc.gc_refs = (-2); g->gc.gc_prev->gc.gc_next =
g->gc.gc_next; g->gc.gc_next->gc.gc_prev = g->gc
.gc_prev; g->gc.gc_next = ((void*)0); } while (0);
;
1384 UnicodeError_clear(self);
1385 Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self);
1386}
1387
1388static int
1389UnicodeError_traverse(PyUnicodeErrorObject *self, visitproc visit, void *arg)
1390{
1391 Py_VISIT(self->encoding)do { if (self->encoding) { int vret = visit((PyObject *)(self
->encoding), arg); if (vret) return vret; } } while (0)
;
1392 Py_VISIT(self->object)do { if (self->object) { int vret = visit((PyObject *)(self
->object), arg); if (vret) return vret; } } while (0)
;
1393 Py_VISIT(self->reason)do { if (self->reason) { int vret = visit((PyObject *)(self
->reason), arg); if (vret) return vret; } } while (0)
;
1394 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
1395}
1396
1397static PyMemberDef UnicodeError_members[] = {
1398 {"encoding", T_OBJECT6, offsetof(PyUnicodeErrorObject, encoding)__builtin_offsetof(PyUnicodeErrorObject, encoding), 0,
1399 PyDoc_STR("exception encoding")"exception encoding"},
1400 {"object", T_OBJECT6, offsetof(PyUnicodeErrorObject, object)__builtin_offsetof(PyUnicodeErrorObject, object), 0,
1401 PyDoc_STR("exception object")"exception object"},
1402 {"start", T_PYSSIZET19, offsetof(PyUnicodeErrorObject, start)__builtin_offsetof(PyUnicodeErrorObject, start), 0,
1403 PyDoc_STR("exception start")"exception start"},
1404 {"end", T_PYSSIZET19, offsetof(PyUnicodeErrorObject, end)__builtin_offsetof(PyUnicodeErrorObject, end), 0,
1405 PyDoc_STR("exception end")"exception end"},
1406 {"reason", T_OBJECT6, offsetof(PyUnicodeErrorObject, reason)__builtin_offsetof(PyUnicodeErrorObject, reason), 0,
1407 PyDoc_STR("exception reason")"exception reason"},
1408 {NULL((void*)0)} /* Sentinel */
1409};
1410
1411
1412/*
1413 * UnicodeEncodeError extends UnicodeError
1414 */
1415
1416static int
1417UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds)
1418{
1419 PyUnicodeErrorObject *err;
1420
1421 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
1422 return -1;
1423
1424 err = (PyUnicodeErrorObject *)self;
1425
1426 Py_CLEAR(err->encoding)do { if (err->encoding) { PyObject *_py_tmp = (PyObject *)
(err->encoding); (err->encoding) = ((void*)0); do { if (
_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0)
{ if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1426, (PyObject *)(_py_tmp)); } else
_Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (
0)
;
1427 Py_CLEAR(err->object)do { if (err->object) { PyObject *_py_tmp = (PyObject *)(err
->object); (err->object) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1427, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1428 Py_CLEAR(err->reason)do { if (err->reason) { PyObject *_py_tmp = (PyObject *)(err
->reason); (err->reason) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1428, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1429
1430 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O!O!nnO!",
1431 &PyUnicode_Type, &err->encoding,
1432 &PyUnicode_Type, &err->object,
1433 &err->start,
1434 &err->end,
1435 &PyUnicode_Type, &err->reason)) {
1436 err->encoding = err->object = err->reason = NULL((void*)0);
1437 return -1;
1438 }
1439
1440 Py_INCREF(err->encoding)( _Py_RefTotal++ , ((PyObject*)(err->encoding))->ob_refcnt
++)
;
1441 Py_INCREF(err->object)( _Py_RefTotal++ , ((PyObject*)(err->object))->ob_refcnt
++)
;
1442 Py_INCREF(err->reason)( _Py_RefTotal++ , ((PyObject*)(err->reason))->ob_refcnt
++)
;
1443
1444 return 0;
1445}
1446
1447static PyObject *
1448UnicodeEncodeError_str(PyObject *self)
1449{
1450 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
1451 PyObject *result = NULL((void*)0);
1452 PyObject *reason_str = NULL((void*)0);
1453 PyObject *encoding_str = NULL((void*)0);
1454
1455 /* Get reason and encoding as strings, which they might not be if
1456 they've been modified after we were contructed. */
1457 reason_str = PyObject_Str(uself->reason);
1458 if (reason_str == NULL((void*)0))
1459 goto done;
1460 encoding_str = PyObject_Str(uself->encoding);
1461 if (encoding_str == NULL((void*)0))
1462 goto done;
1463
1464 if (uself->start < PyUnicode_GET_SIZE(uself->object)((__builtin_expect(!(((((((PyObject*)(uself->object))->
ob_type))->tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn
(__func__, "Objects/exceptions.c", 1464, "PyUnicode_Check(uself->object)"
) : (void)0),(((PyUnicodeObject *)(uself->object))->length
))
&& uself->end == uself->start+1) {
1465 int badchar = (int)PyUnicode_AS_UNICODE(uself->object)((__builtin_expect(!(((((((PyObject*)(uself->object))->
ob_type))->tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn
(__func__, "Objects/exceptions.c", 1465, "PyUnicode_Check(uself->object)"
) : (void)0),(((PyUnicodeObject *)(uself->object))->str
))
[uself->start];
1466 const char *fmt;
1467 if (badchar <= 0xff)
1468 fmt = "'%U' codec can't encode character '\\x%02x' in position %zd: %U";
1469 else if (badchar <= 0xffff)
1470 fmt = "'%U' codec can't encode character '\\u%04x' in position %zd: %U";
1471 else
1472 fmt = "'%U' codec can't encode character '\\U%08x' in position %zd: %U";
1473 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat(
1474 fmt,
1475 encoding_str,
1476 badchar,
1477 uself->start,
1478 reason_str);
1479 }
1480 else {
1481 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat(
1482 "'%U' codec can't encode characters in position %zd-%zd: %U",
1483 encoding_str,
1484 uself->start,
1485 uself->end-1,
1486 reason_str);
1487 }
1488done:
1489 Py_XDECREF(reason_str)do { if ((reason_str) == ((void*)0)) ; else do { if (_Py_RefTotal
-- , --((PyObject*)(reason_str))->ob_refcnt != 0) { if (((
PyObject*)reason_str)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1489, (PyObject *)(reason_str)); } else
_Py_Dealloc((PyObject *)(reason_str)); } while (0); } while (
0)
;
1490 Py_XDECREF(encoding_str)do { if ((encoding_str) == ((void*)0)) ; else do { if (_Py_RefTotal
-- , --((PyObject*)(encoding_str))->ob_refcnt != 0) { if (
((PyObject*)encoding_str)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1490, (PyObject *)(encoding_str)); }
else _Py_Dealloc((PyObject *)(encoding_str)); } while (0); }
while (0)
;
1491 return result;
1492}
1493
1494static PyTypeObject _PyExc_UnicodeEncodeError = {
1495 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 },
1496 "UnicodeEncodeError",
1497 sizeof(PyUnicodeErrorObject), 0,
1498 (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1499 (reprfunc)UnicodeEncodeError_str, 0, 0, 0,
1500 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_BASETYPE(1L<<10) | Py_TPFLAGS_HAVE_GC(1L<<14),
1501 PyDoc_STR("Unicode encoding error.")"Unicode encoding error.", (traverseproc)UnicodeError_traverse,
1502 (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members,
1503 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict)__builtin_offsetof(PyUnicodeErrorObject, dict),
1504 (initproc)UnicodeEncodeError_init, 0, BaseException_new,
1505};
1506PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError;
1507
1508PyObject *
1509PyUnicodeEncodeError_Create(
1510 const char *encoding, const Py_UNICODE *object, Py_ssize_t length,
1511 Py_ssize_t start, Py_ssize_t end, const char *reason)
1512{
1513 return PyObject_CallFunction_PyObject_CallFunction_SizeT(PyExc_UnicodeEncodeError, "su#nns",
1514 encoding, object, length, start, end, reason);
1515}
1516
1517
1518/*
1519 * UnicodeDecodeError extends UnicodeError
1520 */
1521
1522static int
1523UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds)
1524{
1525 PyUnicodeErrorObject *ude;
1526 const char *data;
1527 Py_ssize_t size;
1528
1529 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
1530 return -1;
1531
1532 ude = (PyUnicodeErrorObject *)self;
1533
1534 Py_CLEAR(ude->encoding)do { if (ude->encoding) { PyObject *_py_tmp = (PyObject *)
(ude->encoding); (ude->encoding) = ((void*)0); do { if (
_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0)
{ if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1534, (PyObject *)(_py_tmp)); } else
_Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (
0)
;
1535 Py_CLEAR(ude->object)do { if (ude->object) { PyObject *_py_tmp = (PyObject *)(ude
->object); (ude->object) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1535, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1536 Py_CLEAR(ude->reason)do { if (ude->reason) { PyObject *_py_tmp = (PyObject *)(ude
->reason); (ude->reason) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1536, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1537
1538 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O!OnnO!",
1539 &PyUnicode_Type, &ude->encoding,
1540 &ude->object,
1541 &ude->start,
1542 &ude->end,
1543 &PyUnicode_Type, &ude->reason)) {
1544 ude->encoding = ude->object = ude->reason = NULL((void*)0);
1545 return -1;
1546 }
1547
1548 if (!PyBytes_Check(ude->object)((((((PyObject*)(ude->object))->ob_type))->tp_flags &
((1L<<27))) != 0)
) {
1549 if (PyObject_AsReadBuffer(ude->object, (const void **)&data, &size)) {
1550 ude->encoding = ude->object = ude->reason = NULL((void*)0);
1551 return -1;
1552 }
1553 ude->object = PyBytes_FromStringAndSize(data, size);
1554 }
1555 else {
1556 Py_INCREF(ude->object)( _Py_RefTotal++ , ((PyObject*)(ude->object))->ob_refcnt
++)
;
1557 }
1558
1559 Py_INCREF(ude->encoding)( _Py_RefTotal++ , ((PyObject*)(ude->encoding))->ob_refcnt
++)
;
1560 Py_INCREF(ude->reason)( _Py_RefTotal++ , ((PyObject*)(ude->reason))->ob_refcnt
++)
;
1561
1562 return 0;
1563}
1564
1565static PyObject *
1566UnicodeDecodeError_str(PyObject *self)
1567{
1568 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
1569 PyObject *result = NULL((void*)0);
1570 PyObject *reason_str = NULL((void*)0);
1571 PyObject *encoding_str = NULL((void*)0);
1572
1573 /* Get reason and encoding as strings, which they might not be if
1574 they've been modified after we were contructed. */
1575 reason_str = PyObject_Str(uself->reason);
1576 if (reason_str == NULL((void*)0))
1577 goto done;
1578 encoding_str = PyObject_Str(uself->encoding);
1579 if (encoding_str == NULL((void*)0))
1580 goto done;
1581
1582 if (uself->start < PyBytes_GET_SIZE(uself->object)((__builtin_expect(!(((((((PyObject*)(uself->object))->
ob_type))->tp_flags & ((1L<<27))) != 0)), 0) ? __assert_rtn
(__func__, "Objects/exceptions.c", 1582, "PyBytes_Check(uself->object)"
) : (void)0),(((PyVarObject*)(uself->object))->ob_size)
)
&& uself->end == uself->start+1) {
1583 int byte = (int)(PyBytes_AS_STRING(((PyUnicodeErrorObject *)self)->object)((__builtin_expect(!(((((((PyObject*)(((PyUnicodeErrorObject *
)self)->object))->ob_type))->tp_flags & ((1L<<
27))) != 0)), 0) ? __assert_rtn(__func__, "Objects/exceptions.c"
, 1583, "PyBytes_Check(((PyUnicodeErrorObject *)self)->object)"
) : (void)0), (((PyBytesObject *)(((PyUnicodeErrorObject *)self
)->object))->ob_sval))
[uself->start]&0xff);
1584 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat(
1585 "'%U' codec can't decode byte 0x%02x in position %zd: %U",
1586 encoding_str,
1587 byte,
1588 uself->start,
1589 reason_str);
1590 }
1591 else {
1592 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat(
1593 "'%U' codec can't decode bytes in position %zd-%zd: %U",
1594 encoding_str,
1595 uself->start,
1596 uself->end-1,
1597 reason_str
1598 );
1599 }
1600done:
1601 Py_XDECREF(reason_str)do { if ((reason_str) == ((void*)0)) ; else do { if (_Py_RefTotal
-- , --((PyObject*)(reason_str))->ob_refcnt != 0) { if (((
PyObject*)reason_str)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1601, (PyObject *)(reason_str)); } else
_Py_Dealloc((PyObject *)(reason_str)); } while (0); } while (
0)
;
1602 Py_XDECREF(encoding_str)do { if ((encoding_str) == ((void*)0)) ; else do { if (_Py_RefTotal
-- , --((PyObject*)(encoding_str))->ob_refcnt != 0) { if (
((PyObject*)encoding_str)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1602, (PyObject *)(encoding_str)); }
else _Py_Dealloc((PyObject *)(encoding_str)); } while (0); }
while (0)
;
1603 return result;
1604}
1605
1606static PyTypeObject _PyExc_UnicodeDecodeError = {
1607 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 },
1608 "UnicodeDecodeError",
1609 sizeof(PyUnicodeErrorObject), 0,
1610 (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1611 (reprfunc)UnicodeDecodeError_str, 0, 0, 0,
1612 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_BASETYPE(1L<<10) | Py_TPFLAGS_HAVE_GC(1L<<14),
1613 PyDoc_STR("Unicode decoding error.")"Unicode decoding error.", (traverseproc)UnicodeError_traverse,
1614 (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members,
1615 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict)__builtin_offsetof(PyUnicodeErrorObject, dict),
1616 (initproc)UnicodeDecodeError_init, 0, BaseException_new,
1617};
1618PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError;
1619
1620PyObject *
1621PyUnicodeDecodeError_Create(
1622 const char *encoding, const char *object, Py_ssize_t length,
1623 Py_ssize_t start, Py_ssize_t end, const char *reason)
1624{
1625 return PyObject_CallFunction_PyObject_CallFunction_SizeT(PyExc_UnicodeDecodeError, "sy#nns",
1626 encoding, object, length, start, end, reason);
1627}
1628
1629
1630/*
1631 * UnicodeTranslateError extends UnicodeError
1632 */
1633
1634static int
1635UnicodeTranslateError_init(PyUnicodeErrorObject *self, PyObject *args,
1636 PyObject *kwds)
1637{
1638 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
1639 return -1;
1640
1641 Py_CLEAR(self->object)do { if (self->object) { PyObject *_py_tmp = (PyObject *)(
self->object); (self->object) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1641, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1642 Py_CLEAR(self->reason)do { if (self->reason) { PyObject *_py_tmp = (PyObject *)(
self->reason); (self->reason) = ((void*)0); do { if (_Py_RefTotal
-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject
*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("Objects/exceptions.c"
, 1642, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *
)(_py_tmp)); } while (0); } } while (0)
;
1643
1644 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O!nnO!",
1645 &PyUnicode_Type, &self->object,
1646 &self->start,
1647 &self->end,
1648 &PyUnicode_Type, &self->reason)) {
1649 self->object = self->reason = NULL((void*)0);
1650 return -1;
1651 }
1652
1653 Py_INCREF(self->object)( _Py_RefTotal++ , ((PyObject*)(self->object))->ob_refcnt
++)
;
1654 Py_INCREF(self->reason)( _Py_RefTotal++ , ((PyObject*)(self->reason))->ob_refcnt
++)
;
1655
1656 return 0;
1657}
1658
1659
1660static PyObject *
1661UnicodeTranslateError_str(PyObject *self)
1662{
1663 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
1664 PyObject *result = NULL((void*)0);
1665 PyObject *reason_str = NULL((void*)0);
1666
1667 /* Get reason as a string, which it might not be if it's been
1668 modified after we were contructed. */
1669 reason_str = PyObject_Str(uself->reason);
1670 if (reason_str == NULL((void*)0))
1671 goto done;
1672
1673 if (uself->start < PyUnicode_GET_SIZE(uself->object)((__builtin_expect(!(((((((PyObject*)(uself->object))->
ob_type))->tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn
(__func__, "Objects/exceptions.c", 1673, "PyUnicode_Check(uself->object)"
) : (void)0),(((PyUnicodeObject *)(uself->object))->length
))
&& uself->end == uself->start+1) {
1674 int badchar = (int)PyUnicode_AS_UNICODE(uself->object)((__builtin_expect(!(((((((PyObject*)(uself->object))->
ob_type))->tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn
(__func__, "Objects/exceptions.c", 1674, "PyUnicode_Check(uself->object)"
) : (void)0),(((PyUnicodeObject *)(uself->object))->str
))
[uself->start];
1675 const char *fmt;
1676 if (badchar <= 0xff)
1677 fmt = "can't translate character '\\x%02x' in position %zd: %U";
1678 else if (badchar <= 0xffff)
1679 fmt = "can't translate character '\\u%04x' in position %zd: %U";
1680 else
1681 fmt = "can't translate character '\\U%08x' in position %zd: %U";
1682 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat(
1683 fmt,
1684 badchar,
1685 uself->start,
1686 reason_str
1687 );
1688 } else {
1689 result = PyUnicode_FromFormatPyUnicodeUCS2_FromFormat(
1690 "can't translate characters in position %zd-%zd: %U",
1691 uself->start,
1692 uself->end-1,
1693 reason_str
1694 );
1695 }
1696done:
1697 Py_XDECREF(reason_str)do { if ((reason_str) == ((void*)0)) ; else do { if (_Py_RefTotal
-- , --((PyObject*)(reason_str))->ob_refcnt != 0) { if (((
PyObject*)reason_str)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1697, (PyObject *)(reason_str)); } else
_Py_Dealloc((PyObject *)(reason_str)); } while (0); } while (
0)
;
1698 return result;
1699}
1700
1701static PyTypeObject _PyExc_UnicodeTranslateError = {
1702 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 },
1703 "UnicodeTranslateError",
1704 sizeof(PyUnicodeErrorObject), 0,
1705 (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1706 (reprfunc)UnicodeTranslateError_str, 0, 0, 0,
1707 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_BASETYPE(1L<<10) | Py_TPFLAGS_HAVE_GC(1L<<14),
1708 PyDoc_STR("Unicode translation error.")"Unicode translation error.", (traverseproc)UnicodeError_traverse,
1709 (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members,
1710 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict)__builtin_offsetof(PyUnicodeErrorObject, dict),
1711 (initproc)UnicodeTranslateError_init, 0, BaseException_new,
1712};
1713PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError;
1714
1715PyObject *
1716PyUnicodeTranslateError_Create(
1717 const Py_UNICODE *object, Py_ssize_t length,
1718 Py_ssize_t start, Py_ssize_t end, const char *reason)
1719{
1720 return PyObject_CallFunction_PyObject_CallFunction_SizeT(PyExc_UnicodeTranslateError, "u#nns",
1721 object, length, start, end, reason);
1722}
1723
1724
1725/*
1726 * AssertionError extends Exception
1727 */
1728SimpleExtendsException(PyExc_Exception, AssertionError,static PyTypeObject _PyExc_AssertionError = { { { 0, 0, 1, ((
void*)0) }, 0 }, "AssertionError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Assertion failed.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_AssertionError = (PyObject *)&_PyExc_AssertionError
1729 "Assertion failed.")static PyTypeObject _PyExc_AssertionError = { { { 0, 0, 1, ((
void*)0) }, 0 }, "AssertionError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Assertion failed.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_AssertionError = (PyObject *)&_PyExc_AssertionError
;
1730
1731
1732/*
1733 * ArithmeticError extends Exception
1734 */
1735SimpleExtendsException(PyExc_Exception, ArithmeticError,static PyTypeObject _PyExc_ArithmeticError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "ArithmeticError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for arithmetic errors.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ArithmeticError = (PyObject
*)&_PyExc_ArithmeticError
1736 "Base class for arithmetic errors.")static PyTypeObject _PyExc_ArithmeticError = { { { 0, 0, 1, (
(void*)0) }, 0 }, "ArithmeticError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for arithmetic errors.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ArithmeticError = (PyObject
*)&_PyExc_ArithmeticError
;
1737
1738
1739/*
1740 * FloatingPointError extends ArithmeticError
1741 */
1742SimpleExtendsException(PyExc_ArithmeticError, FloatingPointError,static PyTypeObject _PyExc_FloatingPointError = { { { 0, 0, 1
, ((void*)0) }, 0 }, "FloatingPointError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Floating point operation failed.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_ArithmeticError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_FloatingPointError = (
PyObject *)&_PyExc_FloatingPointError
1743 "Floating point operation failed.")static PyTypeObject _PyExc_FloatingPointError = { { { 0, 0, 1
, ((void*)0) }, 0 }, "FloatingPointError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Floating point operation failed.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_ArithmeticError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_FloatingPointError = (
PyObject *)&_PyExc_FloatingPointError
;
1744
1745
1746/*
1747 * OverflowError extends ArithmeticError
1748 */
1749SimpleExtendsException(PyExc_ArithmeticError, OverflowError,static PyTypeObject _PyExc_OverflowError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "OverflowError", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Result too large to be represented.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_ArithmeticError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_OverflowError = (PyObject
*)&_PyExc_OverflowError
1750 "Result too large to be represented.")static PyTypeObject _PyExc_OverflowError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "OverflowError", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Result too large to be represented.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_ArithmeticError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_OverflowError = (PyObject
*)&_PyExc_OverflowError
;
1751
1752
1753/*
1754 * ZeroDivisionError extends ArithmeticError
1755 */
1756SimpleExtendsException(PyExc_ArithmeticError, ZeroDivisionError,static PyTypeObject _PyExc_ZeroDivisionError = { { { 0, 0, 1,
((void*)0) }, 0 }, "ZeroDivisionError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Second argument to a division or modulo operation was zero."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_ArithmeticError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ZeroDivisionError = (PyObject
*)&_PyExc_ZeroDivisionError
1757 "Second argument to a division or modulo operation was zero.")static PyTypeObject _PyExc_ZeroDivisionError = { { { 0, 0, 1,
((void*)0) }, 0 }, "ZeroDivisionError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Second argument to a division or modulo operation was zero."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_ArithmeticError, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ZeroDivisionError = (PyObject
*)&_PyExc_ZeroDivisionError
;
1758
1759
1760/*
1761 * SystemError extends Exception
1762 */
1763SimpleExtendsException(PyExc_Exception, SystemError,static PyTypeObject _PyExc_SystemError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SystemError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Internal error in the Python interpreter.\n"
"\n" "Please report this to the Python maintainer, along with the traceback,\n"
"the Python version, and the hardware/OS platform and version."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_SystemError = (PyObject
*)&_PyExc_SystemError
1764 "Internal error in the Python interpreter.\n"static PyTypeObject _PyExc_SystemError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SystemError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Internal error in the Python interpreter.\n"
"\n" "Please report this to the Python maintainer, along with the traceback,\n"
"the Python version, and the hardware/OS platform and version."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_SystemError = (PyObject
*)&_PyExc_SystemError
1765 "\n"static PyTypeObject _PyExc_SystemError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SystemError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Internal error in the Python interpreter.\n"
"\n" "Please report this to the Python maintainer, along with the traceback,\n"
"the Python version, and the hardware/OS platform and version."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_SystemError = (PyObject
*)&_PyExc_SystemError
1766 "Please report this to the Python maintainer, along with the traceback,\n"static PyTypeObject _PyExc_SystemError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SystemError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Internal error in the Python interpreter.\n"
"\n" "Please report this to the Python maintainer, along with the traceback,\n"
"the Python version, and the hardware/OS platform and version."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_SystemError = (PyObject
*)&_PyExc_SystemError
1767 "the Python version, and the hardware/OS platform and version.")static PyTypeObject _PyExc_SystemError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SystemError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Internal error in the Python interpreter.\n"
"\n" "Please report this to the Python maintainer, along with the traceback,\n"
"the Python version, and the hardware/OS platform and version."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_SystemError = (PyObject
*)&_PyExc_SystemError
;
1768
1769
1770/*
1771 * ReferenceError extends Exception
1772 */
1773SimpleExtendsException(PyExc_Exception, ReferenceError,static PyTypeObject _PyExc_ReferenceError = { { { 0, 0, 1, ((
void*)0) }, 0 }, "ReferenceError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Weak ref proxy used after referent went away."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ReferenceError = (PyObject
*)&_PyExc_ReferenceError
1774 "Weak ref proxy used after referent went away.")static PyTypeObject _PyExc_ReferenceError = { { { 0, 0, 1, ((
void*)0) }, 0 }, "ReferenceError", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Weak ref proxy used after referent went away."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ReferenceError = (PyObject
*)&_PyExc_ReferenceError
;
1775
1776
1777/*
1778 * MemoryError extends Exception
1779 */
1780
1781#define MEMERRORS_SAVE16 16
1782static PyBaseExceptionObject *memerrors_freelist = NULL((void*)0);
1783static int memerrors_numfree = 0;
1784
1785static PyObject *
1786MemoryError_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1787{
1788 PyBaseExceptionObject *self;
1789
1790 if (type != (PyTypeObject *) PyExc_MemoryError)
1791 return BaseException_new(type, args, kwds);
1792 if (memerrors_freelist == NULL((void*)0))
1793 return BaseException_new(type, args, kwds);
1794 /* Fetch object from freelist and revive it */
1795 self = memerrors_freelist;
1796 self->args = PyTuple_New(0);
1797 /* This shouldn't happen since the empty tuple is persistent */
1798 if (self->args == NULL((void*)0))
1799 return NULL((void*)0);
1800 memerrors_freelist = (PyBaseExceptionObject *) self->dict;
1801 memerrors_numfree--;
1802 self->dict = NULL((void*)0);
1803 _Py_NewReference((PyObject *)self);
1804 _PyObject_GC_TRACK(self)do { PyGC_Head *g = ((PyGC_Head *)(self)-1); if (g->gc.gc_refs
!= (-2)) Py_FatalError("GC object already tracked"); g->gc
.gc_refs = (-3); g->gc.gc_next = _PyGC_generation0; g->
gc.gc_prev = _PyGC_generation0->gc.gc_prev; g->gc.gc_prev
->gc.gc_next = g; _PyGC_generation0->gc.gc_prev = g; } while
(0);
;
1805 return (PyObject *)self;
1806}
1807
1808static void
1809MemoryError_dealloc(PyBaseExceptionObject *self)
1810{
1811 _PyObject_GC_UNTRACK(self)do { PyGC_Head *g = ((PyGC_Head *)(self)-1); (__builtin_expect
(!(g->gc.gc_refs != (-2)), 0) ? __assert_rtn(__func__, "Objects/exceptions.c"
, 1811, "g->gc.gc_refs != _PyGC_REFS_UNTRACKED") : (void)0
); g->gc.gc_refs = (-2); g->gc.gc_prev->gc.gc_next =
g->gc.gc_next; g->gc.gc_next->gc.gc_prev = g->gc
.gc_prev; g->gc.gc_next = ((void*)0); } while (0);
;
1812 BaseException_clear(self);
1813 if (memerrors_numfree >= MEMERRORS_SAVE16)
1814 Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self);
1815 else {
1816 self->dict = (PyObject *) memerrors_freelist;
1817 memerrors_freelist = self;
1818 memerrors_numfree++;
1819 }
1820}
1821
1822static void
1823preallocate_memerrors(void)
1824{
1825 /* We create enough MemoryErrors and then decref them, which will fill
1826 up the freelist. */
1827 int i;
1828 PyObject *errors[MEMERRORS_SAVE16];
1829 for (i = 0; i < MEMERRORS_SAVE16; i++) {
1830 errors[i] = MemoryError_new((PyTypeObject *) PyExc_MemoryError,
1831 NULL((void*)0), NULL((void*)0));
1832 if (!errors[i])
1833 Py_FatalError("Could not preallocate MemoryError object");
1834 }
1835 for (i = 0; i < MEMERRORS_SAVE16; i++) {
1836 Py_DECREF(errors[i])do { if (_Py_RefTotal-- , --((PyObject*)(errors[i]))->ob_refcnt
!= 0) { if (((PyObject*)errors[i])->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 1836, (PyObject *)(errors[i])); } else
_Py_Dealloc((PyObject *)(errors[i])); } while (0)
;
1837 }
1838}
1839
1840static void
1841free_preallocated_memerrors(void)
1842{
1843 while (memerrors_freelist != NULL((void*)0)) {
1844 PyObject *self = (PyObject *) memerrors_freelist;
1845 memerrors_freelist = (PyBaseExceptionObject *) memerrors_freelist->dict;
1846 Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self);
1847 }
1848}
1849
1850
1851static PyTypeObject _PyExc_MemoryError = {
1852 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 },
1853 "MemoryError",
1854 sizeof(PyBaseExceptionObject),
1855 0, (destructor)MemoryError_dealloc, 0, 0, 0, 0, 0, 0, 0,
1856 0, 0, 0, 0, 0, 0, 0,
1857 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_BASETYPE(1L<<10) | Py_TPFLAGS_HAVE_GC(1L<<14),
1858 PyDoc_STR("Out of memory.")"Out of memory.", (traverseproc)BaseException_traverse,
1859 (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception,
1860 0, 0, 0, offsetof(PyBaseExceptionObject, dict)__builtin_offsetof(PyBaseExceptionObject, dict),
1861 (initproc)BaseException_init, 0, MemoryError_new
1862};
1863PyObject *PyExc_MemoryError = (PyObject *) &_PyExc_MemoryError;
1864
1865
1866/*
1867 * BufferError extends Exception
1868 */
1869SimpleExtendsException(PyExc_Exception, BufferError, "Buffer error.")static PyTypeObject _PyExc_BufferError = { { { 0, 0, 1, ((void
*)0) }, 0 }, "BufferError", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Buffer error.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_BufferError = (PyObject *)&_PyExc_BufferError
;
1870
1871
1872/* Warning category docstrings */
1873
1874/*
1875 * Warning extends Exception
1876 */
1877SimpleExtendsException(PyExc_Exception, Warning,static PyTypeObject _PyExc_Warning = { { { 0, 0, 1, ((void*)0
) }, 0 }, "Warning", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Base class for warning categories.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_Warning = (PyObject *)&_PyExc_Warning
1878 "Base class for warning categories.")static PyTypeObject _PyExc_Warning = { { { 0, 0, 1, ((void*)0
) }, 0 }, "Warning", sizeof(PyBaseExceptionObject), 0, (destructor
)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, ( 0 | (1L<<18) | 0) | (1L<<10) | (1L<<
14), "Base class for warning categories.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_Warning = (PyObject *)&_PyExc_Warning
;
1879
1880
1881/*
1882 * UserWarning extends Warning
1883 */
1884SimpleExtendsException(PyExc_Warning, UserWarning,static PyTypeObject _PyExc_UserWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "UserWarning", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings generated by user code."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_UserWarning = (PyObject
*)&_PyExc_UserWarning
1885 "Base class for warnings generated by user code.")static PyTypeObject _PyExc_UserWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "UserWarning", sizeof(PyBaseExceptionObject), 0,
(destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings generated by user code."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_UserWarning = (PyObject
*)&_PyExc_UserWarning
;
1886
1887
1888/*
1889 * DeprecationWarning extends Warning
1890 */
1891SimpleExtendsException(PyExc_Warning, DeprecationWarning,static PyTypeObject _PyExc_DeprecationWarning = { { { 0, 0, 1
, ((void*)0) }, 0 }, "DeprecationWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about deprecated features."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_DeprecationWarning = (
PyObject *)&_PyExc_DeprecationWarning
1892 "Base class for warnings about deprecated features.")static PyTypeObject _PyExc_DeprecationWarning = { { { 0, 0, 1
, ((void*)0) }, 0 }, "DeprecationWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about deprecated features."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_DeprecationWarning = (
PyObject *)&_PyExc_DeprecationWarning
;
1893
1894
1895/*
1896 * PendingDeprecationWarning extends Warning
1897 */
1898SimpleExtendsException(PyExc_Warning, PendingDeprecationWarning,static PyTypeObject _PyExc_PendingDeprecationWarning = { { { 0
, 0, 1, ((void*)0) }, 0 }, "PendingDeprecationWarning", sizeof
(PyBaseExceptionObject), 0, (destructor)BaseException_dealloc
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<
18) | 0) | (1L<<10) | (1L<<14), "Base class for warnings about features which will be deprecated\n"
"in the future.", (traverseproc)BaseException_traverse, (inquiry
)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_PendingDeprecationWarning = (PyObject *)&_PyExc_PendingDeprecationWarning
1899 "Base class for warnings about features which will be deprecated\n"static PyTypeObject _PyExc_PendingDeprecationWarning = { { { 0
, 0, 1, ((void*)0) }, 0 }, "PendingDeprecationWarning", sizeof
(PyBaseExceptionObject), 0, (destructor)BaseException_dealloc
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<
18) | 0) | (1L<<10) | (1L<<14), "Base class for warnings about features which will be deprecated\n"
"in the future.", (traverseproc)BaseException_traverse, (inquiry
)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_PendingDeprecationWarning = (PyObject *)&_PyExc_PendingDeprecationWarning
1900 "in the future.")static PyTypeObject _PyExc_PendingDeprecationWarning = { { { 0
, 0, 1, ((void*)0) }, 0 }, "PendingDeprecationWarning", sizeof
(PyBaseExceptionObject), 0, (destructor)BaseException_dealloc
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<
18) | 0) | (1L<<10) | (1L<<14), "Base class for warnings about features which will be deprecated\n"
"in the future.", (traverseproc)BaseException_traverse, (inquiry
)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_PendingDeprecationWarning = (PyObject *)&_PyExc_PendingDeprecationWarning
;
1901
1902
1903/*
1904 * SyntaxWarning extends Warning
1905 */
1906SimpleExtendsException(PyExc_Warning, SyntaxWarning,static PyTypeObject _PyExc_SyntaxWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SyntaxWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about dubious syntax."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_SyntaxWarning = (PyObject
*)&_PyExc_SyntaxWarning
1907 "Base class for warnings about dubious syntax.")static PyTypeObject _PyExc_SyntaxWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "SyntaxWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about dubious syntax."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_SyntaxWarning = (PyObject
*)&_PyExc_SyntaxWarning
;
1908
1909
1910/*
1911 * RuntimeWarning extends Warning
1912 */
1913SimpleExtendsException(PyExc_Warning, RuntimeWarning,static PyTypeObject _PyExc_RuntimeWarning = { { { 0, 0, 1, ((
void*)0) }, 0 }, "RuntimeWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about dubious runtime behavior."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_RuntimeWarning = (PyObject
*)&_PyExc_RuntimeWarning
1914 "Base class for warnings about dubious runtime behavior.")static PyTypeObject _PyExc_RuntimeWarning = { { { 0, 0, 1, ((
void*)0) }, 0 }, "RuntimeWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about dubious runtime behavior."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_RuntimeWarning = (PyObject
*)&_PyExc_RuntimeWarning
;
1915
1916
1917/*
1918 * FutureWarning extends Warning
1919 */
1920SimpleExtendsException(PyExc_Warning, FutureWarning,static PyTypeObject _PyExc_FutureWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "FutureWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about constructs that will change semantically\n"
"in the future.", (traverseproc)BaseException_traverse, (inquiry
)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_FutureWarning = (PyObject *)&_PyExc_FutureWarning
1921 "Base class for warnings about constructs that will change semantically\n"static PyTypeObject _PyExc_FutureWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "FutureWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about constructs that will change semantically\n"
"in the future.", (traverseproc)BaseException_traverse, (inquiry
)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_FutureWarning = (PyObject *)&_PyExc_FutureWarning
1922 "in the future.")static PyTypeObject _PyExc_FutureWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "FutureWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about constructs that will change semantically\n"
"in the future.", (traverseproc)BaseException_traverse, (inquiry
)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_FutureWarning = (PyObject *)&_PyExc_FutureWarning
;
1923
1924
1925/*
1926 * ImportWarning extends Warning
1927 */
1928SimpleExtendsException(PyExc_Warning, ImportWarning,static PyTypeObject _PyExc_ImportWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "ImportWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about probable mistakes in module imports"
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ImportWarning = (PyObject
*)&_PyExc_ImportWarning
1929 "Base class for warnings about probable mistakes in module imports")static PyTypeObject _PyExc_ImportWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "ImportWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about probable mistakes in module imports"
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ImportWarning = (PyObject
*)&_PyExc_ImportWarning
;
1930
1931
1932/*
1933 * UnicodeWarning extends Warning
1934 */
1935SimpleExtendsException(PyExc_Warning, UnicodeWarning,static PyTypeObject _PyExc_UnicodeWarning = { { { 0, 0, 1, ((
void*)0) }, 0 }, "UnicodeWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about Unicode related problems, mostly\n"
"related to conversion problems.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_UnicodeWarning = (PyObject *)&_PyExc_UnicodeWarning
1936 "Base class for warnings about Unicode related problems, mostly\n"static PyTypeObject _PyExc_UnicodeWarning = { { { 0, 0, 1, ((
void*)0) }, 0 }, "UnicodeWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about Unicode related problems, mostly\n"
"related to conversion problems.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_UnicodeWarning = (PyObject *)&_PyExc_UnicodeWarning
1937 "related to conversion problems.")static PyTypeObject _PyExc_UnicodeWarning = { { { 0, 0, 1, ((
void*)0) }, 0 }, "UnicodeWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about Unicode related problems, mostly\n"
"related to conversion problems.", (traverseproc)BaseException_traverse
, (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning
, 0, 0, 0, __builtin_offsetof(PyBaseExceptionObject, dict), (
initproc)BaseException_init, 0, BaseException_new,}; PyObject
*PyExc_UnicodeWarning = (PyObject *)&_PyExc_UnicodeWarning
;
1938
1939
1940/*
1941 * BytesWarning extends Warning
1942 */
1943SimpleExtendsException(PyExc_Warning, BytesWarning,static PyTypeObject _PyExc_BytesWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "BytesWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about bytes and buffer related problems, mostly\n"
"related to conversion from str or comparing to str.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_BytesWarning = (PyObject
*)&_PyExc_BytesWarning
1944 "Base class for warnings about bytes and buffer related problems, mostly\n"static PyTypeObject _PyExc_BytesWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "BytesWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about bytes and buffer related problems, mostly\n"
"related to conversion from str or comparing to str.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_BytesWarning = (PyObject
*)&_PyExc_BytesWarning
1945 "related to conversion from str or comparing to str.")static PyTypeObject _PyExc_BytesWarning = { { { 0, 0, 1, ((void
*)0) }, 0 }, "BytesWarning", sizeof(PyBaseExceptionObject), 0
, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<10) |
(1L<<14), "Base class for warnings about bytes and buffer related problems, mostly\n"
"related to conversion from str or comparing to str.", (traverseproc
)BaseException_traverse, (inquiry)BaseException_clear, 0, 0, 0
, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_BytesWarning = (PyObject
*)&_PyExc_BytesWarning
;
1946
1947
1948/*
1949 * ResourceWarning extends Warning
1950 */
1951SimpleExtendsException(PyExc_Warning, ResourceWarning,static PyTypeObject _PyExc_ResourceWarning = { { { 0, 0, 1, (
(void*)0) }, 0 }, "ResourceWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about resource usage."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ResourceWarning = (PyObject
*)&_PyExc_ResourceWarning
1952 "Base class for warnings about resource usage.")static PyTypeObject _PyExc_ResourceWarning = { { { 0, 0, 1, (
(void*)0) }, 0 }, "ResourceWarning", sizeof(PyBaseExceptionObject
), 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, ( 0 | (1L<<18) | 0) | (1L<<
10) | (1L<<14), "Base class for warnings about resource usage."
, (traverseproc)BaseException_traverse, (inquiry)BaseException_clear
, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Warning, 0, 0, 0, __builtin_offsetof
(PyBaseExceptionObject, dict), (initproc)BaseException_init, 0
, BaseException_new,}; PyObject *PyExc_ResourceWarning = (PyObject
*)&_PyExc_ResourceWarning
;
1953
1954
1955
1956/* Pre-computed RuntimeError instance for when recursion depth is reached.
1957 Meant to be used when normalizing the exception for exceeding the recursion
1958 depth will cause its own infinite recursion.
1959*/
1960PyObject *PyExc_RecursionErrorInst = NULL((void*)0);
1961
1962#define PRE_INIT(TYPE)if (PyType_Ready(&_PyExc_TYPE) < 0) Py_FatalError("exceptions bootstrapping error."
);
if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \
1963 Py_FatalError("exceptions bootstrapping error.");
1964
1965#define POST_INIT(TYPE)( _Py_RefTotal++ , ((PyObject*)(PyExc_TYPE))->ob_refcnt++)
; if (PyDict_SetItemString(bdict, "TYPE", PyExc_TYPE)) Py_FatalError
("Module dictionary insertion problem.");
Py_INCREF(PyExc_ ## TYPE)( _Py_RefTotal++ , ((PyObject*)(PyExc_ ## TYPE))->ob_refcnt
++)
; \
1966 if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \
1967 Py_FatalError("Module dictionary insertion problem.");
1968
1969
1970void
1971_PyExc_Init(void)
1972{
1973 PyObject *bltinmod, *bdict;
1974
1975 PRE_INIT(BaseException)if (PyType_Ready(&_PyExc_BaseException) < 0) Py_FatalError
("exceptions bootstrapping error.");
1976 PRE_INIT(Exception)if (PyType_Ready(&_PyExc_Exception) < 0) Py_FatalError
("exceptions bootstrapping error.");
1977 PRE_INIT(TypeError)if (PyType_Ready(&_PyExc_TypeError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1978 PRE_INIT(StopIteration)if (PyType_Ready(&_PyExc_StopIteration) < 0) Py_FatalError
("exceptions bootstrapping error.");
1979 PRE_INIT(GeneratorExit)if (PyType_Ready(&_PyExc_GeneratorExit) < 0) Py_FatalError
("exceptions bootstrapping error.");
1980 PRE_INIT(SystemExit)if (PyType_Ready(&_PyExc_SystemExit) < 0) Py_FatalError
("exceptions bootstrapping error.");
1981 PRE_INIT(KeyboardInterrupt)if (PyType_Ready(&_PyExc_KeyboardInterrupt) < 0) Py_FatalError
("exceptions bootstrapping error.");
1982 PRE_INIT(ImportError)if (PyType_Ready(&_PyExc_ImportError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1983 PRE_INIT(EnvironmentError)if (PyType_Ready(&_PyExc_EnvironmentError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1984 PRE_INIT(IOError)if (PyType_Ready(&_PyExc_IOError) < 0) Py_FatalError("exceptions bootstrapping error."
);
1985 PRE_INIT(OSError)if (PyType_Ready(&_PyExc_OSError) < 0) Py_FatalError("exceptions bootstrapping error."
);
1986#ifdef MS_WINDOWS
1987 PRE_INIT(WindowsError)if (PyType_Ready(&_PyExc_WindowsError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1988#endif
1989#ifdef __VMS
1990 PRE_INIT(VMSError)if (PyType_Ready(&_PyExc_VMSError) < 0) Py_FatalError(
"exceptions bootstrapping error.");
1991#endif
1992 PRE_INIT(EOFError)if (PyType_Ready(&_PyExc_EOFError) < 0) Py_FatalError(
"exceptions bootstrapping error.");
1993 PRE_INIT(RuntimeError)if (PyType_Ready(&_PyExc_RuntimeError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1994 PRE_INIT(NotImplementedError)if (PyType_Ready(&_PyExc_NotImplementedError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1995 PRE_INIT(NameError)if (PyType_Ready(&_PyExc_NameError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1996 PRE_INIT(UnboundLocalError)if (PyType_Ready(&_PyExc_UnboundLocalError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1997 PRE_INIT(AttributeError)if (PyType_Ready(&_PyExc_AttributeError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1998 PRE_INIT(SyntaxError)if (PyType_Ready(&_PyExc_SyntaxError) < 0) Py_FatalError
("exceptions bootstrapping error.");
1999 PRE_INIT(IndentationError)if (PyType_Ready(&_PyExc_IndentationError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2000 PRE_INIT(TabError)if (PyType_Ready(&_PyExc_TabError) < 0) Py_FatalError(
"exceptions bootstrapping error.");
2001 PRE_INIT(LookupError)if (PyType_Ready(&_PyExc_LookupError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2002 PRE_INIT(IndexError)if (PyType_Ready(&_PyExc_IndexError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2003 PRE_INIT(KeyError)if (PyType_Ready(&_PyExc_KeyError) < 0) Py_FatalError(
"exceptions bootstrapping error.");
2004 PRE_INIT(ValueError)if (PyType_Ready(&_PyExc_ValueError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2005 PRE_INIT(UnicodeError)if (PyType_Ready(&_PyExc_UnicodeError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2006 PRE_INIT(UnicodeEncodeError)if (PyType_Ready(&_PyExc_UnicodeEncodeError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2007 PRE_INIT(UnicodeDecodeError)if (PyType_Ready(&_PyExc_UnicodeDecodeError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2008 PRE_INIT(UnicodeTranslateError)if (PyType_Ready(&_PyExc_UnicodeTranslateError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2009 PRE_INIT(AssertionError)if (PyType_Ready(&_PyExc_AssertionError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2010 PRE_INIT(ArithmeticError)if (PyType_Ready(&_PyExc_ArithmeticError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2011 PRE_INIT(FloatingPointError)if (PyType_Ready(&_PyExc_FloatingPointError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2012 PRE_INIT(OverflowError)if (PyType_Ready(&_PyExc_OverflowError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2013 PRE_INIT(ZeroDivisionError)if (PyType_Ready(&_PyExc_ZeroDivisionError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2014 PRE_INIT(SystemError)if (PyType_Ready(&_PyExc_SystemError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2015 PRE_INIT(ReferenceError)if (PyType_Ready(&_PyExc_ReferenceError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2016 PRE_INIT(BufferError)if (PyType_Ready(&_PyExc_BufferError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2017 PRE_INIT(MemoryError)if (PyType_Ready(&_PyExc_MemoryError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2018 PRE_INIT(BufferError)if (PyType_Ready(&_PyExc_BufferError) < 0) Py_FatalError
("exceptions bootstrapping error.");
2019 PRE_INIT(Warning)if (PyType_Ready(&_PyExc_Warning) < 0) Py_FatalError("exceptions bootstrapping error."
);
2020 PRE_INIT(UserWarning)if (PyType_Ready(&_PyExc_UserWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2021 PRE_INIT(DeprecationWarning)if (PyType_Ready(&_PyExc_DeprecationWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2022 PRE_INIT(PendingDeprecationWarning)if (PyType_Ready(&_PyExc_PendingDeprecationWarning) < 0
) Py_FatalError("exceptions bootstrapping error.");
2023 PRE_INIT(SyntaxWarning)if (PyType_Ready(&_PyExc_SyntaxWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2024 PRE_INIT(RuntimeWarning)if (PyType_Ready(&_PyExc_RuntimeWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2025 PRE_INIT(FutureWarning)if (PyType_Ready(&_PyExc_FutureWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2026 PRE_INIT(ImportWarning)if (PyType_Ready(&_PyExc_ImportWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2027 PRE_INIT(UnicodeWarning)if (PyType_Ready(&_PyExc_UnicodeWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2028 PRE_INIT(BytesWarning)if (PyType_Ready(&_PyExc_BytesWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2029 PRE_INIT(ResourceWarning)if (PyType_Ready(&_PyExc_ResourceWarning) < 0) Py_FatalError
("exceptions bootstrapping error.");
2030
2031 bltinmod = PyImport_ImportModule("builtins");
2032 if (bltinmod == NULL((void*)0))
2033 Py_FatalError("exceptions bootstrapping error.");
2034 bdict = PyModule_GetDict(bltinmod);
2035 if (bdict == NULL((void*)0))
2036 Py_FatalError("exceptions bootstrapping error.");
2037
2038 POST_INIT(BaseException)( _Py_RefTotal++ , ((PyObject*)(PyExc_BaseException))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "BaseException", PyExc_BaseException
)) Py_FatalError("Module dictionary insertion problem.");
2039 POST_INIT(Exception)( _Py_RefTotal++ , ((PyObject*)(PyExc_Exception))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "Exception", PyExc_Exception
)) Py_FatalError("Module dictionary insertion problem.");
2040 POST_INIT(TypeError)( _Py_RefTotal++ , ((PyObject*)(PyExc_TypeError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "TypeError", PyExc_TypeError
)) Py_FatalError("Module dictionary insertion problem.");
2041 POST_INIT(StopIteration)( _Py_RefTotal++ , ((PyObject*)(PyExc_StopIteration))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "StopIteration", PyExc_StopIteration
)) Py_FatalError("Module dictionary insertion problem.");
2042 POST_INIT(GeneratorExit)( _Py_RefTotal++ , ((PyObject*)(PyExc_GeneratorExit))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "GeneratorExit", PyExc_GeneratorExit
)) Py_FatalError("Module dictionary insertion problem.");
2043 POST_INIT(SystemExit)( _Py_RefTotal++ , ((PyObject*)(PyExc_SystemExit))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "SystemExit", PyExc_SystemExit
)) Py_FatalError("Module dictionary insertion problem.");
2044 POST_INIT(KeyboardInterrupt)( _Py_RefTotal++ , ((PyObject*)(PyExc_KeyboardInterrupt))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "KeyboardInterrupt"
, PyExc_KeyboardInterrupt)) Py_FatalError("Module dictionary insertion problem."
);
2045 POST_INIT(ImportError)( _Py_RefTotal++ , ((PyObject*)(PyExc_ImportError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "ImportError", PyExc_ImportError
)) Py_FatalError("Module dictionary insertion problem.");
2046 POST_INIT(EnvironmentError)( _Py_RefTotal++ , ((PyObject*)(PyExc_EnvironmentError))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "EnvironmentError"
, PyExc_EnvironmentError)) Py_FatalError("Module dictionary insertion problem."
);
2047 POST_INIT(IOError)( _Py_RefTotal++ , ((PyObject*)(PyExc_IOError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "IOError", PyExc_IOError
)) Py_FatalError("Module dictionary insertion problem.");
2048 POST_INIT(OSError)( _Py_RefTotal++ , ((PyObject*)(PyExc_OSError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "OSError", PyExc_OSError
)) Py_FatalError("Module dictionary insertion problem.");
2049#ifdef MS_WINDOWS
2050 POST_INIT(WindowsError)( _Py_RefTotal++ , ((PyObject*)(PyExc_WindowsError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "WindowsError", PyExc_WindowsError
)) Py_FatalError("Module dictionary insertion problem.");
2051#endif
2052#ifdef __VMS
2053 POST_INIT(VMSError)( _Py_RefTotal++ , ((PyObject*)(PyExc_VMSError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "VMSError", PyExc_VMSError
)) Py_FatalError("Module dictionary insertion problem.");
2054#endif
2055 POST_INIT(EOFError)( _Py_RefTotal++ , ((PyObject*)(PyExc_EOFError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "EOFError", PyExc_EOFError
)) Py_FatalError("Module dictionary insertion problem.");
2056 POST_INIT(RuntimeError)( _Py_RefTotal++ , ((PyObject*)(PyExc_RuntimeError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "RuntimeError", PyExc_RuntimeError
)) Py_FatalError("Module dictionary insertion problem.");
2057 POST_INIT(NotImplementedError)( _Py_RefTotal++ , ((PyObject*)(PyExc_NotImplementedError))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "NotImplementedError"
, PyExc_NotImplementedError)) Py_FatalError("Module dictionary insertion problem."
);
2058 POST_INIT(NameError)( _Py_RefTotal++ , ((PyObject*)(PyExc_NameError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "NameError", PyExc_NameError
)) Py_FatalError("Module dictionary insertion problem.");
2059 POST_INIT(UnboundLocalError)( _Py_RefTotal++ , ((PyObject*)(PyExc_UnboundLocalError))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "UnboundLocalError"
, PyExc_UnboundLocalError)) Py_FatalError("Module dictionary insertion problem."
);
2060 POST_INIT(AttributeError)( _Py_RefTotal++ , ((PyObject*)(PyExc_AttributeError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "AttributeError", PyExc_AttributeError
)) Py_FatalError("Module dictionary insertion problem.");
2061 POST_INIT(SyntaxError)( _Py_RefTotal++ , ((PyObject*)(PyExc_SyntaxError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "SyntaxError", PyExc_SyntaxError
)) Py_FatalError("Module dictionary insertion problem.");
2062 POST_INIT(IndentationError)( _Py_RefTotal++ , ((PyObject*)(PyExc_IndentationError))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "IndentationError"
, PyExc_IndentationError)) Py_FatalError("Module dictionary insertion problem."
);
2063 POST_INIT(TabError)( _Py_RefTotal++ , ((PyObject*)(PyExc_TabError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "TabError", PyExc_TabError
)) Py_FatalError("Module dictionary insertion problem.");
2064 POST_INIT(LookupError)( _Py_RefTotal++ , ((PyObject*)(PyExc_LookupError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "LookupError", PyExc_LookupError
)) Py_FatalError("Module dictionary insertion problem.");
2065 POST_INIT(IndexError)( _Py_RefTotal++ , ((PyObject*)(PyExc_IndexError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "IndexError", PyExc_IndexError
)) Py_FatalError("Module dictionary insertion problem.");
2066 POST_INIT(KeyError)( _Py_RefTotal++ , ((PyObject*)(PyExc_KeyError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "KeyError", PyExc_KeyError
)) Py_FatalError("Module dictionary insertion problem.");
2067 POST_INIT(ValueError)( _Py_RefTotal++ , ((PyObject*)(PyExc_ValueError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "ValueError", PyExc_ValueError
)) Py_FatalError("Module dictionary insertion problem.");
2068 POST_INIT(UnicodeError)( _Py_RefTotal++ , ((PyObject*)(PyExc_UnicodeError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "UnicodeError", PyExc_UnicodeError
)) Py_FatalError("Module dictionary insertion problem.");
2069 POST_INIT(UnicodeEncodeError)( _Py_RefTotal++ , ((PyObject*)(PyExc_UnicodeEncodeError))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "UnicodeEncodeError"
, PyExc_UnicodeEncodeError)) Py_FatalError("Module dictionary insertion problem."
);
2070 POST_INIT(UnicodeDecodeError)( _Py_RefTotal++ , ((PyObject*)(PyExc_UnicodeDecodeError))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "UnicodeDecodeError"
, PyExc_UnicodeDecodeError)) Py_FatalError("Module dictionary insertion problem."
);
2071 POST_INIT(UnicodeTranslateError)( _Py_RefTotal++ , ((PyObject*)(PyExc_UnicodeTranslateError))
->ob_refcnt++); if (PyDict_SetItemString(bdict, "UnicodeTranslateError"
, PyExc_UnicodeTranslateError)) Py_FatalError("Module dictionary insertion problem."
);
2072 POST_INIT(AssertionError)( _Py_RefTotal++ , ((PyObject*)(PyExc_AssertionError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "AssertionError", PyExc_AssertionError
)) Py_FatalError("Module dictionary insertion problem.");
2073 POST_INIT(ArithmeticError)( _Py_RefTotal++ , ((PyObject*)(PyExc_ArithmeticError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "ArithmeticError", PyExc_ArithmeticError
)) Py_FatalError("Module dictionary insertion problem.");
2074 POST_INIT(FloatingPointError)( _Py_RefTotal++ , ((PyObject*)(PyExc_FloatingPointError))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "FloatingPointError"
, PyExc_FloatingPointError)) Py_FatalError("Module dictionary insertion problem."
);
2075 POST_INIT(OverflowError)( _Py_RefTotal++ , ((PyObject*)(PyExc_OverflowError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "OverflowError", PyExc_OverflowError
)) Py_FatalError("Module dictionary insertion problem.");
2076 POST_INIT(ZeroDivisionError)( _Py_RefTotal++ , ((PyObject*)(PyExc_ZeroDivisionError))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "ZeroDivisionError"
, PyExc_ZeroDivisionError)) Py_FatalError("Module dictionary insertion problem."
);
2077 POST_INIT(SystemError)( _Py_RefTotal++ , ((PyObject*)(PyExc_SystemError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "SystemError", PyExc_SystemError
)) Py_FatalError("Module dictionary insertion problem.");
2078 POST_INIT(ReferenceError)( _Py_RefTotal++ , ((PyObject*)(PyExc_ReferenceError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "ReferenceError", PyExc_ReferenceError
)) Py_FatalError("Module dictionary insertion problem.");
2079 POST_INIT(BufferError)( _Py_RefTotal++ , ((PyObject*)(PyExc_BufferError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "BufferError", PyExc_BufferError
)) Py_FatalError("Module dictionary insertion problem.");
2080 POST_INIT(MemoryError)( _Py_RefTotal++ , ((PyObject*)(PyExc_MemoryError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "MemoryError", PyExc_MemoryError
)) Py_FatalError("Module dictionary insertion problem.");
2081 POST_INIT(BufferError)( _Py_RefTotal++ , ((PyObject*)(PyExc_BufferError))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "BufferError", PyExc_BufferError
)) Py_FatalError("Module dictionary insertion problem.");
2082 POST_INIT(Warning)( _Py_RefTotal++ , ((PyObject*)(PyExc_Warning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "Warning", PyExc_Warning
)) Py_FatalError("Module dictionary insertion problem.");
2083 POST_INIT(UserWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_UserWarning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "UserWarning", PyExc_UserWarning
)) Py_FatalError("Module dictionary insertion problem.");
2084 POST_INIT(DeprecationWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_DeprecationWarning))->
ob_refcnt++); if (PyDict_SetItemString(bdict, "DeprecationWarning"
, PyExc_DeprecationWarning)) Py_FatalError("Module dictionary insertion problem."
);
2085 POST_INIT(PendingDeprecationWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_PendingDeprecationWarning
))->ob_refcnt++); if (PyDict_SetItemString(bdict, "PendingDeprecationWarning"
, PyExc_PendingDeprecationWarning)) Py_FatalError("Module dictionary insertion problem."
);
2086 POST_INIT(SyntaxWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_SyntaxWarning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "SyntaxWarning", PyExc_SyntaxWarning
)) Py_FatalError("Module dictionary insertion problem.");
2087 POST_INIT(RuntimeWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_RuntimeWarning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "RuntimeWarning", PyExc_RuntimeWarning
)) Py_FatalError("Module dictionary insertion problem.");
2088 POST_INIT(FutureWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_FutureWarning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "FutureWarning", PyExc_FutureWarning
)) Py_FatalError("Module dictionary insertion problem.");
2089 POST_INIT(ImportWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_ImportWarning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "ImportWarning", PyExc_ImportWarning
)) Py_FatalError("Module dictionary insertion problem.");
2090 POST_INIT(UnicodeWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_UnicodeWarning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "UnicodeWarning", PyExc_UnicodeWarning
)) Py_FatalError("Module dictionary insertion problem.");
2091 POST_INIT(BytesWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_BytesWarning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "BytesWarning", PyExc_BytesWarning
)) Py_FatalError("Module dictionary insertion problem.");
2092 POST_INIT(ResourceWarning)( _Py_RefTotal++ , ((PyObject*)(PyExc_ResourceWarning))->ob_refcnt
++); if (PyDict_SetItemString(bdict, "ResourceWarning", PyExc_ResourceWarning
)) Py_FatalError("Module dictionary insertion problem.");
2093
2094 preallocate_memerrors();
2095
2096 PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL((void*)0), NULL((void*)0));
2097 if (!PyExc_RecursionErrorInst)
2098 Py_FatalError("Cannot pre-allocate RuntimeError instance for "
2099 "recursion errors");
2100 else {
2101 PyBaseExceptionObject *err_inst =
2102 (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
2103 PyObject *args_tuple;
2104 PyObject *exc_message;
2105 exc_message = PyUnicode_FromStringPyUnicodeUCS2_FromString("maximum recursion depth exceeded");
2106 if (!exc_message)
2107 Py_FatalError("cannot allocate argument for RuntimeError "
2108 "pre-allocation");
2109 args_tuple = PyTuple_Pack(1, exc_message);
2110 if (!args_tuple)
2111 Py_FatalError("cannot allocate tuple for RuntimeError "
2112 "pre-allocation");
2113 Py_DECREF(exc_message)do { if (_Py_RefTotal-- , --((PyObject*)(exc_message))->ob_refcnt
!= 0) { if (((PyObject*)exc_message)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 2113, (PyObject *)(exc_message)); } else
_Py_Dealloc((PyObject *)(exc_message)); } while (0)
;
2114 if (BaseException_init(err_inst, args_tuple, NULL((void*)0)))
2115 Py_FatalError("init of pre-allocated RuntimeError failed");
2116 Py_DECREF(args_tuple)do { if (_Py_RefTotal-- , --((PyObject*)(args_tuple))->ob_refcnt
!= 0) { if (((PyObject*)args_tuple)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 2116, (PyObject *)(args_tuple)); } else
_Py_Dealloc((PyObject *)(args_tuple)); } while (0)
;
2117 }
2118
2119 Py_DECREF(bltinmod)do { if (_Py_RefTotal-- , --((PyObject*)(bltinmod))->ob_refcnt
!= 0) { if (((PyObject*)bltinmod)->ob_refcnt < 0) _Py_NegativeRefcount
("Objects/exceptions.c", 2119, (PyObject *)(bltinmod)); } else
_Py_Dealloc((PyObject *)(bltinmod)); } while (0)
;
2120}
2121
2122void
2123_PyExc_Fini(void)
2124{
2125 Py_CLEAR(PyExc_RecursionErrorInst)do { if (PyExc_RecursionErrorInst) { PyObject *_py_tmp = (PyObject
*)(PyExc_RecursionErrorInst); (PyExc_RecursionErrorInst) = (
(void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))
->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt
< 0) _Py_NegativeRefcount("Objects/exceptions.c", 2125, (
PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp
)); } while (0); } } while (0)
;
2126 free_preallocated_memerrors();
2127}