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