Mercurial > cpython-lru_cache-weakref
annotate Objects/exceptions.c @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | 04e1f701aeaa |
| children |
| rev | line source |
|---|---|
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1 /* |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2 * New exceptions.c written in Iceland by Richard Jones and Georg Brandl. |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3 * |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4 * Thanks go to Tim Peters and Michael Hudson for debugging. |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5 */ |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
6 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
7 #define PY_SSIZE_T_CLEAN |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
8 #include <Python.h> |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
9 #include "structmember.h" |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
10 #include "osdefs.h" |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
11 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
12 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
13 /* Compatibility aliases */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
14 PyObject *PyExc_EnvironmentError = NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
15 PyObject *PyExc_IOError = NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
16 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
17 PyObject *PyExc_WindowsError = NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
18 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
19 #ifdef __VMS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
20 PyObject *PyExc_VMSError = NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
21 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
22 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
23 /* The dict map from errno codes to OSError subclasses */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
24 static PyObject *errnomap = NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
25 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
26 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
27 /* NOTE: If the exception class hierarchy changes, don't forget to update |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
28 * Lib/test/exception_hierarchy.txt |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
29 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
30 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
31 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
32 * BaseException |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
33 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
34 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
35 BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
36 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
37 PyBaseExceptionObject *self; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
38 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
39 self = (PyBaseExceptionObject *)type->tp_alloc(type, 0); |
|
41554
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41501
diff
changeset
|
40 if (!self) |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41501
diff
changeset
|
41 return NULL; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
42 /* the dict is created on the fly in PyObject_GenericSetAttr */ |
|
41749
b085eb66b7f6
Merged revisions 55342-55406 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41716
diff
changeset
|
43 self->dict = NULL; |
|
43188
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
44 self->traceback = self->cause = self->context = NULL; |
|
76942
b0eb7d2a9542
PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents:
76898
diff
changeset
|
45 self->suppress_context = 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
46 |
|
82413
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
47 if (args) { |
|
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
48 self->args = args; |
|
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
49 Py_INCREF(args); |
|
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
50 return (PyObject *)self; |
|
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
51 } |
|
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
52 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
53 self->args = PyTuple_New(0); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
54 if (!self->args) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
55 Py_DECREF(self); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
56 return NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
57 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
58 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
59 return (PyObject *)self; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
60 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
61 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
62 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
63 BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
64 { |
|
82413
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
65 PyObject *tmp; |
|
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
66 |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
67 if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds)) |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
68 return -1; |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
69 |
|
82413
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
70 tmp = self->args; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
71 self->args = args; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
72 Py_INCREF(self->args); |
|
82413
2c9f7ed28384
#17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents:
74864
diff
changeset
|
73 Py_XDECREF(tmp); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
74 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
75 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
76 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
77 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
78 static int |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
79 BaseException_clear(PyBaseExceptionObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
80 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
81 Py_CLEAR(self->dict); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
82 Py_CLEAR(self->args); |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
83 Py_CLEAR(self->traceback); |
|
43188
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
84 Py_CLEAR(self->cause); |
|
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
85 Py_CLEAR(self->context); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
86 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
87 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
88 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
89 static void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
90 BaseException_dealloc(PyBaseExceptionObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
91 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
92 _PyObject_GC_UNTRACK(self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
93 BaseException_clear(self); |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
94 Py_TYPE(self)->tp_free((PyObject *)self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
95 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
96 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
97 static int |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
98 BaseException_traverse(PyBaseExceptionObject *self, visitproc visit, void *arg) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
99 { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
100 Py_VISIT(self->dict); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
101 Py_VISIT(self->args); |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
102 Py_VISIT(self->traceback); |
|
43188
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
103 Py_VISIT(self->cause); |
|
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
104 Py_VISIT(self->context); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
105 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
106 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
107 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
108 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
109 BaseException_str(PyBaseExceptionObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
110 { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
111 switch (PyTuple_GET_SIZE(self->args)) { |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
112 case 0: |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
113 return PyUnicode_FromString(""); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
114 case 1: |
|
43866
8ed0280c2ab6
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
Thomas Heller <theller@ctypes.org>
parents:
43777
diff
changeset
|
115 return PyObject_Str(PyTuple_GET_ITEM(self->args, 0)); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
116 default: |
|
43866
8ed0280c2ab6
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
Thomas Heller <theller@ctypes.org>
parents:
43777
diff
changeset
|
117 return PyObject_Str(self->args); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
118 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
119 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
120 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
121 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
122 BaseException_repr(PyBaseExceptionObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
123 { |
|
86484
3055e61f1e66
Issue #1772673: The type of `char*` arguments now changed to `const char*`.
Serhiy Storchaka <storchaka@gmail.com>
parents:
84445
diff
changeset
|
124 const char *name; |
|
3055e61f1e66
Issue #1772673: The type of `char*` arguments now changed to `const char*`.
Serhiy Storchaka <storchaka@gmail.com>
parents:
84445
diff
changeset
|
125 const char *dot; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
126 |
|
86484
3055e61f1e66
Issue #1772673: The type of `char*` arguments now changed to `const char*`.
Serhiy Storchaka <storchaka@gmail.com>
parents:
84445
diff
changeset
|
127 name = Py_TYPE(self)->tp_name; |
|
3055e61f1e66
Issue #1772673: The type of `char*` arguments now changed to `const char*`.
Serhiy Storchaka <storchaka@gmail.com>
parents:
84445
diff
changeset
|
128 dot = (const char *) strrchr(name, '.'); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
129 if (dot != NULL) name = dot+1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
130 |
|
41782
bee8d01ef42c
Add a format specifier %R to PyUnicode_FromFormat(), which embeds
Walter Dörwald <walter@livinglogic.de>
parents:
41769
diff
changeset
|
131 return PyUnicode_FromFormat("%s%R", name, self->args); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
132 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
133 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
134 /* Pickling support */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
135 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
136 BaseException_reduce(PyBaseExceptionObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
137 { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
138 if (self->args && self->dict) |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
139 return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict); |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
140 else |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
141 return PyTuple_Pack(2, Py_TYPE(self), self->args); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
142 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
143 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
144 /* |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
145 * Needed for backward compatibility, since exceptions used to store |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
146 * all their attributes in the __dict__. Code is taken from cPickle's |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
147 * load_build function. |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
148 */ |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
149 static PyObject * |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
150 BaseException_setstate(PyObject *self, PyObject *state) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
151 { |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
152 PyObject *d_key, *d_value; |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
153 Py_ssize_t i = 0; |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
154 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
155 if (state != Py_None) { |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
156 if (!PyDict_Check(state)) { |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
157 PyErr_SetString(PyExc_TypeError, "state is not a dictionary"); |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
158 return NULL; |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
159 } |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
160 while (PyDict_Next(state, &i, &d_key, &d_value)) { |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
161 if (PyObject_SetAttr(self, d_key, d_value) < 0) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
162 return NULL; |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
163 } |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
164 } |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
165 Py_RETURN_NONE; |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
166 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
167 |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
168 static PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
169 BaseException_with_traceback(PyObject *self, PyObject *tb) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
170 if (PyException_SetTraceback(self, tb)) |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
171 return NULL; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
172 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
173 Py_INCREF(self); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
174 return self; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
175 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
176 |
|
46682
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
177 PyDoc_STRVAR(with_traceback_doc, |
|
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
178 "Exception.with_traceback(tb) --\n\ |
|
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
179 set self.__traceback__ to tb and return self."); |
|
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
180 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
181 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
182 static PyMethodDef BaseException_methods[] = { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
183 {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS }, |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
184 {"__setstate__", (PyCFunction)BaseException_setstate, METH_O }, |
|
46682
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
185 {"with_traceback", (PyCFunction)BaseException_with_traceback, METH_O, |
|
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
186 with_traceback_doc}, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
187 {NULL, NULL, 0, NULL}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
188 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
189 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
190 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
191 BaseException_get_args(PyBaseExceptionObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
192 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
193 if (self->args == NULL) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
194 Py_INCREF(Py_None); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
195 return Py_None; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
196 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
197 Py_INCREF(self->args); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
198 return self->args; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
199 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
200 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
201 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
202 BaseException_set_args(PyBaseExceptionObject *self, PyObject *val) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
203 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
204 PyObject *seq; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
205 if (val == NULL) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
206 PyErr_SetString(PyExc_TypeError, "args may not be deleted"); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
207 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
208 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
209 seq = PySequence_Tuple(val); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
210 if (!seq) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
211 return -1; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
212 Py_CLEAR(self->args); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
213 self->args = seq; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
214 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
215 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
216 |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
217 static PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
218 BaseException_get_tb(PyBaseExceptionObject *self) |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
219 { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
220 if (self->traceback == NULL) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
221 Py_INCREF(Py_None); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
222 return Py_None; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
223 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
224 Py_INCREF(self->traceback); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
225 return self->traceback; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
226 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
227 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
228 static int |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
229 BaseException_set_tb(PyBaseExceptionObject *self, PyObject *tb) |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
230 { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
231 if (tb == NULL) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
232 PyErr_SetString(PyExc_TypeError, "__traceback__ may not be deleted"); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
233 return -1; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
234 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
235 else if (!(tb == Py_None || PyTraceBack_Check(tb))) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
236 PyErr_SetString(PyExc_TypeError, |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
237 "__traceback__ must be a traceback or None"); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
238 return -1; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
239 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
240 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
241 Py_XINCREF(tb); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
242 Py_XDECREF(self->traceback); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
243 self->traceback = tb; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
244 return 0; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
245 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
246 |
|
52509
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
247 static PyObject * |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
248 BaseException_get_context(PyObject *self) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
249 PyObject *res = PyException_GetContext(self); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
250 if (res) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
251 return res; /* new reference already returned above */ |
|
52509
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
252 Py_RETURN_NONE; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
253 } |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
254 |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
255 static int |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
256 BaseException_set_context(PyObject *self, PyObject *arg) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
257 if (arg == NULL) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
258 PyErr_SetString(PyExc_TypeError, "__context__ may not be deleted"); |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
259 return -1; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
260 } else if (arg == Py_None) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
261 arg = NULL; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
262 } else if (!PyExceptionInstance_Check(arg)) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
263 PyErr_SetString(PyExc_TypeError, "exception context must be None " |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
264 "or derive from BaseException"); |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
265 return -1; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
266 } else { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
267 /* PyException_SetContext steals this reference */ |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
268 Py_INCREF(arg); |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59128
diff
changeset
|
269 } |
|
52509
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
270 PyException_SetContext(self, arg); |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
271 return 0; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
272 } |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
273 |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
274 static PyObject * |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
275 BaseException_get_cause(PyObject *self) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
276 PyObject *res = PyException_GetCause(self); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
277 if (res) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
278 return res; /* new reference already returned above */ |
|
52509
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
279 Py_RETURN_NONE; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
280 } |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
281 |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
282 static int |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
283 BaseException_set_cause(PyObject *self, PyObject *arg) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
284 if (arg == NULL) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
285 PyErr_SetString(PyExc_TypeError, "__cause__ may not be deleted"); |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
286 return -1; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
287 } else if (arg == Py_None) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
288 arg = NULL; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
289 } else if (!PyExceptionInstance_Check(arg)) { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
290 PyErr_SetString(PyExc_TypeError, "exception cause must be None " |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
291 "or derive from BaseException"); |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
292 return -1; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
293 } else { |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
294 /* PyException_SetCause steals this reference */ |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
295 Py_INCREF(arg); |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59128
diff
changeset
|
296 } |
|
52509
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
297 PyException_SetCause(self, arg); |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
298 return 0; |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
299 } |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
300 |
|
41716
00c02c4488ce
Merged revisions 55325-55327 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41611
diff
changeset
|
301 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
302 static PyGetSetDef BaseException_getset[] = { |
|
75051
f029312764b4
use new generic __dict__ descriptor implementations
Benjamin Peterson <benjamin@python.org>
parents:
74865
diff
changeset
|
303 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
304 {"args", (getter)BaseException_get_args, (setter)BaseException_set_args}, |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
305 {"__traceback__", (getter)BaseException_get_tb, (setter)BaseException_set_tb}, |
|
52509
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
306 {"__context__", (getter)BaseException_get_context, |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
307 (setter)BaseException_set_context, PyDoc_STR("exception context")}, |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
308 {"__cause__", (getter)BaseException_get_cause, |
|
d12b02abe6dc
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents:
51579
diff
changeset
|
309 (setter)BaseException_set_cause, PyDoc_STR("exception cause")}, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
310 {NULL}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
311 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
312 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
313 |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
314 PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
315 PyException_GetTraceback(PyObject *self) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
316 PyBaseExceptionObject *base_self = (PyBaseExceptionObject *)self; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
317 Py_XINCREF(base_self->traceback); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
318 return base_self->traceback; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
319 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
320 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
321 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
322 int |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
323 PyException_SetTraceback(PyObject *self, PyObject *tb) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
324 return BaseException_set_tb((PyBaseExceptionObject *)self, tb); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
325 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
326 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
327 PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
328 PyException_GetCause(PyObject *self) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
329 PyObject *cause = ((PyBaseExceptionObject *)self)->cause; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
330 Py_XINCREF(cause); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
331 return cause; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
332 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
333 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
334 /* Steals a reference to cause */ |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
335 void |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
336 PyException_SetCause(PyObject *self, PyObject *cause) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
337 PyObject *old_cause = ((PyBaseExceptionObject *)self)->cause; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
338 ((PyBaseExceptionObject *)self)->cause = cause; |
|
76942
b0eb7d2a9542
PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents:
76898
diff
changeset
|
339 ((PyBaseExceptionObject *)self)->suppress_context = 1; |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
340 Py_XDECREF(old_cause); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
341 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
342 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
343 PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
344 PyException_GetContext(PyObject *self) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
345 PyObject *context = ((PyBaseExceptionObject *)self)->context; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
346 Py_XINCREF(context); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
347 return context; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
348 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
349 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
350 /* Steals a reference to context */ |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
351 void |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
352 PyException_SetContext(PyObject *self, PyObject *context) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
353 PyObject *old_context = ((PyBaseExceptionObject *)self)->context; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
354 ((PyBaseExceptionObject *)self)->context = context; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
355 Py_XDECREF(old_context); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
356 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
357 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
358 |
|
76942
b0eb7d2a9542
PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents:
76898
diff
changeset
|
359 static struct PyMemberDef BaseException_members[] = { |
|
b0eb7d2a9542
PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents:
76898
diff
changeset
|
360 {"__suppress_context__", T_BOOL, |
| 76988 | 361 offsetof(PyBaseExceptionObject, suppress_context)}, |
| 362 {NULL} | |
|
76942
b0eb7d2a9542
PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents:
76898
diff
changeset
|
363 }; |
|
b0eb7d2a9542
PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents:
76898
diff
changeset
|
364 |
|
b0eb7d2a9542
PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents:
76898
diff
changeset
|
365 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
366 static PyTypeObject _PyExc_BaseException = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42305
diff
changeset
|
367 PyVarObject_HEAD_INIT(NULL, 0) |
|
40949
e759fd8d95ae
Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents:
40909
diff
changeset
|
368 "BaseException", /*tp_name*/ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
369 sizeof(PyBaseExceptionObject), /*tp_basicsize*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
370 0, /*tp_itemsize*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
371 (destructor)BaseException_dealloc, /*tp_dealloc*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
372 0, /*tp_print*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
373 0, /*tp_getattr*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
374 0, /*tp_setattr*/ |
|
51271
87fbbf22adf3
Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
50886
diff
changeset
|
375 0, /* tp_reserved; */ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
376 (reprfunc)BaseException_repr, /*tp_repr*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
377 0, /*tp_as_number*/ |
|
40959
0ea52558bdfe
Remove the ability to slice/index on exceptions per PEP 352.
Brett Cannon <bcannon@gmail.com>
parents:
40949
diff
changeset
|
378 0, /*tp_as_sequence*/ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
379 0, /*tp_as_mapping*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
380 0, /*tp_hash */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
381 0, /*tp_call*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
382 (reprfunc)BaseException_str, /*tp_str*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
383 PyObject_GenericGetAttr, /*tp_getattro*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
384 PyObject_GenericSetAttr, /*tp_setattro*/ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
385 0, /*tp_as_buffer*/ |
|
40909
f2f0b41f270d
Merged revisions 53875-53911 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40626
diff
changeset
|
386 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59128
diff
changeset
|
387 Py_TPFLAGS_BASE_EXC_SUBCLASS, /*tp_flags*/ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
388 PyDoc_STR("Common base class for all exceptions"), /* tp_doc */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
389 (traverseproc)BaseException_traverse, /* tp_traverse */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
390 (inquiry)BaseException_clear, /* tp_clear */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
391 0, /* tp_richcompare */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
392 0, /* tp_weaklistoffset */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
393 0, /* tp_iter */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
394 0, /* tp_iternext */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
395 BaseException_methods, /* tp_methods */ |
|
76942
b0eb7d2a9542
PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents:
76898
diff
changeset
|
396 BaseException_members, /* tp_members */ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
397 BaseException_getset, /* tp_getset */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
398 0, /* tp_base */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
399 0, /* tp_dict */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
400 0, /* tp_descr_get */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
401 0, /* tp_descr_set */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
402 offsetof(PyBaseExceptionObject, dict), /* tp_dictoffset */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
403 (initproc)BaseException_init, /* tp_init */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
404 0, /* tp_alloc */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
405 BaseException_new, /* tp_new */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
406 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
407 /* the CPython API expects exceptions to be (PyObject *) - both a hold-over |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
408 from the previous implmentation and also allowing Python objects to be used |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
409 in the API */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
410 PyObject *PyExc_BaseException = (PyObject *)&_PyExc_BaseException; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
411 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
412 /* note these macros omit the last semicolon so the macro invocation may |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
413 * include it and not look strange. |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
414 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
415 #define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC) \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
416 static PyTypeObject _PyExc_ ## EXCNAME = { \ |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42305
diff
changeset
|
417 PyVarObject_HEAD_INIT(NULL, 0) \ |
|
40949
e759fd8d95ae
Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents:
40909
diff
changeset
|
418 # EXCNAME, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
419 sizeof(PyBaseExceptionObject), \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
420 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
421 0, 0, 0, 0, 0, 0, 0, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
422 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
423 PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
424 (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
425 0, 0, 0, offsetof(PyBaseExceptionObject, dict), \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
426 (initproc)BaseException_init, 0, BaseException_new,\ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
427 }; \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
428 PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
429 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
430 #define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC) \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
431 static PyTypeObject _PyExc_ ## EXCNAME = { \ |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42305
diff
changeset
|
432 PyVarObject_HEAD_INIT(NULL, 0) \ |
|
40949
e759fd8d95ae
Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents:
40909
diff
changeset
|
433 # EXCNAME, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
434 sizeof(Py ## EXCSTORE ## Object), \ |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
435 0, (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
436 0, 0, 0, 0, 0, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
437 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
438 PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \ |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
439 (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
440 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
441 (initproc)EXCSTORE ## _init, 0, 0, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
442 }; \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
443 PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
444 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
445 #define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCNEW, \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
446 EXCMETHODS, EXCMEMBERS, EXCGETSET, \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
447 EXCSTR, EXCDOC) \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
448 static PyTypeObject _PyExc_ ## EXCNAME = { \ |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42305
diff
changeset
|
449 PyVarObject_HEAD_INIT(NULL, 0) \ |
|
40949
e759fd8d95ae
Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents:
40909
diff
changeset
|
450 # EXCNAME, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
451 sizeof(Py ## EXCSTORE ## Object), 0, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
452 (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
453 (reprfunc)EXCSTR, 0, 0, 0, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
454 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
455 PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
456 (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, EXCMETHODS, \ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
457 EXCMEMBERS, EXCGETSET, &_ ## EXCBASE, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
458 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
459 (initproc)EXCSTORE ## _init, 0, EXCNEW,\ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
460 }; \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
461 PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
462 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
463 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
464 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
465 * Exception extends BaseException |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
466 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
467 SimpleExtendsException(PyExc_BaseException, Exception, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
468 "Common base class for all non-exit exceptions."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
469 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
470 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
471 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
472 * TypeError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
473 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
474 SimpleExtendsException(PyExc_Exception, TypeError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
475 "Inappropriate argument type."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
476 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
477 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
478 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
479 * StopIteration extends Exception |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
480 */ |
|
74356
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
481 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
482 static PyMemberDef StopIteration_members[] = { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
483 {"value", T_OBJECT, offsetof(PyStopIterationObject, value), 0, |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
484 PyDoc_STR("generator return value")}, |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
485 {NULL} /* Sentinel */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
486 }; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
487 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
488 static int |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
489 StopIteration_init(PyStopIterationObject *self, PyObject *args, PyObject *kwds) |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
490 { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
491 Py_ssize_t size = PyTuple_GET_SIZE(args); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
492 PyObject *value; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
493 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
494 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
495 return -1; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
496 Py_CLEAR(self->value); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
497 if (size > 0) |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
498 value = PyTuple_GET_ITEM(args, 0); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
499 else |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
500 value = Py_None; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
501 Py_INCREF(value); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
502 self->value = value; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
503 return 0; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
504 } |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
505 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
506 static int |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
507 StopIteration_clear(PyStopIterationObject *self) |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
508 { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
509 Py_CLEAR(self->value); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
510 return BaseException_clear((PyBaseExceptionObject *)self); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
511 } |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
512 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
513 static void |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
514 StopIteration_dealloc(PyStopIterationObject *self) |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
515 { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
516 _PyObject_GC_UNTRACK(self); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
517 StopIteration_clear(self); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
518 Py_TYPE(self)->tp_free((PyObject *)self); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
519 } |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
520 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
521 static int |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
522 StopIteration_traverse(PyStopIterationObject *self, visitproc visit, void *arg) |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
523 { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
524 Py_VISIT(self->value); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
525 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
526 } |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
527 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
528 ComplexExtendsException( |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
529 PyExc_Exception, /* base */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
530 StopIteration, /* name */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
531 StopIteration, /* prefix for *_init, etc */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
532 0, /* new */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
533 0, /* methods */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
534 StopIteration_members, /* members */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
535 0, /* getset */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
536 0, /* str */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
537 "Signal the end from iterator.__next__()." |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
538 ); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
539 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
540 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
541 /* |
|
44129
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44125
diff
changeset
|
542 * GeneratorExit extends BaseException |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
543 */ |
|
44129
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44125
diff
changeset
|
544 SimpleExtendsException(PyExc_BaseException, GeneratorExit, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
545 "Request that a generator exit."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
546 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
547 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
548 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
549 * SystemExit extends BaseException |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
550 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
551 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
552 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
553 SystemExit_init(PySystemExitObject *self, PyObject *args, PyObject *kwds) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
554 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
555 Py_ssize_t size = PyTuple_GET_SIZE(args); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
556 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
557 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
558 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
559 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
560 if (size == 0) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
561 return 0; |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
562 Py_CLEAR(self->code); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
563 if (size == 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
564 self->code = PyTuple_GET_ITEM(args, 0); |
|
70403
772d9825f154
SystemExit_init(): avoid an useless test
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68257
diff
changeset
|
565 else /* size > 1 */ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
566 self->code = args; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
567 Py_INCREF(self->code); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
568 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
569 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
570 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
571 static int |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
572 SystemExit_clear(PySystemExitObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
573 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
574 Py_CLEAR(self->code); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
575 return BaseException_clear((PyBaseExceptionObject *)self); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
576 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
577 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
578 static void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
579 SystemExit_dealloc(PySystemExitObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
580 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
581 _PyObject_GC_UNTRACK(self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
582 SystemExit_clear(self); |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
583 Py_TYPE(self)->tp_free((PyObject *)self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
584 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
585 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
586 static int |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
587 SystemExit_traverse(PySystemExitObject *self, visitproc visit, void *arg) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
588 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
589 Py_VISIT(self->code); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
590 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
591 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
592 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
593 static PyMemberDef SystemExit_members[] = { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
594 {"code", T_OBJECT, offsetof(PySystemExitObject, code), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
595 PyDoc_STR("exception code")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
596 {NULL} /* Sentinel */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
597 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
598 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
599 ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit, |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
600 0, 0, SystemExit_members, 0, 0, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
601 "Request to exit from the interpreter."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
602 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
603 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
604 * KeyboardInterrupt extends BaseException |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
605 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
606 SimpleExtendsException(PyExc_BaseException, KeyboardInterrupt, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
607 "Program interrupted by user."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
608 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
609 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
610 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
611 * ImportError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
612 */ |
|
76272
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
613 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
614 static int |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
615 ImportError_init(PyImportErrorObject *self, PyObject *args, PyObject *kwds) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
616 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
617 PyObject *msg = NULL; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
618 PyObject *name = NULL; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
619 PyObject *path = NULL; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
620 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
621 /* Macro replacement doesn't allow ## to start the first line of a macro, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
622 so we move the assignment and NULL check into the if-statement. */ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
623 #define GET_KWD(kwd) { \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
624 kwd = PyDict_GetItemString(kwds, #kwd); \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
625 if (kwd) { \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
626 Py_CLEAR(self->kwd); \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
627 self->kwd = kwd; \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
628 Py_INCREF(self->kwd);\ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
629 if (PyDict_DelItemString(kwds, #kwd)) \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
630 return -1; \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
631 } \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
632 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
633 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
634 if (kwds) { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
635 GET_KWD(name); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
636 GET_KWD(path); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
637 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
638 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
639 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
640 return -1; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
641 if (PyTuple_GET_SIZE(args) != 1) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
642 return 0; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
643 if (!PyArg_UnpackTuple(args, "ImportError", 1, 1, &msg)) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
644 return -1; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
645 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
646 Py_CLEAR(self->msg); /* replacing */ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
647 self->msg = msg; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
648 Py_INCREF(self->msg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
649 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
650 return 0; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
651 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
652 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
653 static int |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
654 ImportError_clear(PyImportErrorObject *self) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
655 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
656 Py_CLEAR(self->msg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
657 Py_CLEAR(self->name); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
658 Py_CLEAR(self->path); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
659 return BaseException_clear((PyBaseExceptionObject *)self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
660 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
661 |
|
76272
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
662 static void |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
663 ImportError_dealloc(PyImportErrorObject *self) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
664 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
665 _PyObject_GC_UNTRACK(self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
666 ImportError_clear(self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
667 Py_TYPE(self)->tp_free((PyObject *)self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
668 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
669 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
670 static int |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
671 ImportError_traverse(PyImportErrorObject *self, visitproc visit, void *arg) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
672 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
673 Py_VISIT(self->msg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
674 Py_VISIT(self->name); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
675 Py_VISIT(self->path); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
676 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
677 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
678 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
679 static PyObject * |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
680 ImportError_str(PyImportErrorObject *self) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
681 { |
|
78737
91909962d7f5
Issue #15778: Coerce ImportError.args to a string when it isn't
Brett Cannon <brett@python.org>
parents:
78304
diff
changeset
|
682 if (self->msg && PyUnicode_CheckExact(self->msg)) { |
|
76272
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
683 Py_INCREF(self->msg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
684 return self->msg; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
685 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
686 else { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
687 return BaseException_str((PyBaseExceptionObject *)self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
688 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
689 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
690 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
691 static PyMemberDef ImportError_members[] = { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
692 {"msg", T_OBJECT, offsetof(PyImportErrorObject, msg), 0, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
693 PyDoc_STR("exception message")}, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
694 {"name", T_OBJECT, offsetof(PyImportErrorObject, name), 0, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
695 PyDoc_STR("module name")}, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
696 {"path", T_OBJECT, offsetof(PyImportErrorObject, path), 0, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
697 PyDoc_STR("module path")}, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
698 {NULL} /* Sentinel */ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
699 }; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
700 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
701 static PyMethodDef ImportError_methods[] = { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
702 {NULL} |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
703 }; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
704 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
705 ComplexExtendsException(PyExc_Exception, ImportError, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
706 ImportError, 0 /* new */, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
707 ImportError_methods, ImportError_members, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
708 0 /* getset */, ImportError_str, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
709 "Import can't find module, or can't find name in " |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
710 "module."); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
711 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
712 /* |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
713 * OSError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
714 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
715 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
716 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
717 #include "errmap.h" |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
718 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
719 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
720 /* Where a function has a single filename, such as open() or some |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
721 * of the os module functions, PyErr_SetFromErrnoWithFilename() is |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
722 * called, giving a third argument which is the filename. But, so |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
723 * that old code using in-place unpacking doesn't break, e.g.: |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
724 * |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
725 * except OSError, (errno, strerror): |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
726 * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
727 * we hack args so that it only contains two items. This also |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
728 * means we need our own __str__() which prints out the filename |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
729 * when it was supplied. |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
730 */ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
731 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
732 /* This function doesn't cleanup on error, the caller should */ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
733 static int |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
734 oserror_parse_args(PyObject **p_args, |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
735 PyObject **myerrno, PyObject **strerror, |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
736 PyObject **filename |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
737 #ifdef MS_WINDOWS |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
738 , PyObject **winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
739 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
740 ) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
741 { |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
742 Py_ssize_t nargs; |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
743 PyObject *args = *p_args; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
744 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
745 nargs = PyTuple_GET_SIZE(args); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
746 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
747 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
748 if (nargs >= 2 && nargs <= 4) { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
749 if (!PyArg_UnpackTuple(args, "OSError", 2, 4, |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
750 myerrno, strerror, filename, winerror)) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
751 return -1; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
752 if (*winerror && PyLong_Check(*winerror)) { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
753 long errcode, winerrcode; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
754 PyObject *newargs; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
755 Py_ssize_t i; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
756 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
757 winerrcode = PyLong_AsLong(*winerror); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
758 if (winerrcode == -1 && PyErr_Occurred()) |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
759 return -1; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
760 /* Set errno to the corresponding POSIX errno (overriding |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
761 first argument). Windows Socket error codes (>= 10000) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
762 have the same value as their POSIX counterparts. |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
763 */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
764 if (winerrcode < 10000) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
765 errcode = winerror_to_errno(winerrcode); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
766 else |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
767 errcode = winerrcode; |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
768 *myerrno = PyLong_FromLong(errcode); |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
769 if (!*myerrno) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
770 return -1; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
771 newargs = PyTuple_New(nargs); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
772 if (!newargs) |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
773 return -1; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
774 PyTuple_SET_ITEM(newargs, 0, *myerrno); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
775 for (i = 1; i < nargs; i++) { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
776 PyObject *val = PyTuple_GET_ITEM(args, i); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
777 Py_INCREF(val); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
778 PyTuple_SET_ITEM(newargs, i, val); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
779 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
780 Py_DECREF(args); |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
781 args = *p_args = newargs; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
782 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
783 } |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
784 #else |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
785 if (nargs >= 2 && nargs <= 3) { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
786 if (!PyArg_UnpackTuple(args, "OSError", 2, 3, |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
787 myerrno, strerror, filename)) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
788 return -1; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
789 } |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
790 #endif |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
791 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
792 return 0; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
793 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
794 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
795 static int |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
796 oserror_init(PyOSErrorObject *self, PyObject **p_args, |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
797 PyObject *myerrno, PyObject *strerror, |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
798 PyObject *filename |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
799 #ifdef MS_WINDOWS |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
800 , PyObject *winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
801 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
802 ) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
803 { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
804 PyObject *args = *p_args; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
805 Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
806 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
807 /* self->filename will remain Py_None otherwise */ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
808 if (filename && filename != Py_None) { |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
809 if (Py_TYPE(self) == (PyTypeObject *) PyExc_BlockingIOError && |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
810 PyNumber_Check(filename)) { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
811 /* BlockingIOError's 3rd argument can be the number of |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
812 * characters written. |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
813 */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
814 self->written = PyNumber_AsSsize_t(filename, PyExc_ValueError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
815 if (self->written == -1 && PyErr_Occurred()) |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
816 return -1; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
817 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
818 else { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
819 Py_INCREF(filename); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
820 self->filename = filename; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
821 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
822 if (nargs >= 2 && nargs <= 3) { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
823 /* filename is removed from the args tuple (for compatibility |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
824 purposes, see test_exceptions.py) */ |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
825 PyObject *subslice = PyTuple_GetSlice(args, 0, 2); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
826 if (!subslice) |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
827 return -1; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
828 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
829 Py_DECREF(args); /* replacing args */ |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
830 *p_args = args = subslice; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
831 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
832 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
833 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
834 Py_XINCREF(myerrno); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
835 self->myerrno = myerrno; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
836 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
837 Py_XINCREF(strerror); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
838 self->strerror = strerror; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
839 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
840 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
841 Py_XINCREF(winerror); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
842 self->winerror = winerror; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
843 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
844 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
845 /* Steals the reference to args */ |
|
77894
1cbab581bf1e
Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents:
77476
diff
changeset
|
846 Py_CLEAR(self->args); |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
847 self->args = args; |
|
87106
61a712066770
Issue #19429, #19437: fix error handling in the OSError constructor
Victor Stinner <victor.stinner@gmail.com>
parents:
87097
diff
changeset
|
848 *p_args = args = NULL; |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
849 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
850 return 0; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
851 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
852 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
853 static PyObject * |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
854 OSError_new(PyTypeObject *type, PyObject *args, PyObject *kwds); |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
855 static int |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
856 OSError_init(PyOSErrorObject *self, PyObject *args, PyObject *kwds); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
857 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
858 static int |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
859 oserror_use_init(PyTypeObject *type) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
860 { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
861 /* When __init__ is defined in a OSError subclass, we want any |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
862 extraneous argument to __new__ to be ignored. The only reasonable |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
863 solution, given __new__ takes a variable number of arguments, |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
864 is to defer arg parsing and initialization to __init__. |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
865 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
866 But when __new__ is overriden as well, it should call our __new__ |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
867 with the right arguments. |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
868 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
869 (see http://bugs.python.org/issue12555#msg148829 ) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
870 */ |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
871 if (type->tp_init != (initproc) OSError_init && |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
872 type->tp_new == (newfunc) OSError_new) { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
873 assert((PyObject *) type != PyExc_OSError); |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
874 return 1; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
875 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
876 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
877 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
878 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
879 static PyObject * |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
880 OSError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
881 { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
882 PyOSErrorObject *self = NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
883 PyObject *myerrno = NULL, *strerror = NULL, *filename = NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
884 #ifdef MS_WINDOWS |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
885 PyObject *winerror = NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
886 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
887 |
|
87106
61a712066770
Issue #19429, #19437: fix error handling in the OSError constructor
Victor Stinner <victor.stinner@gmail.com>
parents:
87097
diff
changeset
|
888 Py_INCREF(args); |
|
61a712066770
Issue #19429, #19437: fix error handling in the OSError constructor
Victor Stinner <victor.stinner@gmail.com>
parents:
87097
diff
changeset
|
889 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
890 if (!oserror_use_init(type)) { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
891 if (!_PyArg_NoKeywords(type->tp_name, kwds)) |
|
87106
61a712066770
Issue #19429, #19437: fix error handling in the OSError constructor
Victor Stinner <victor.stinner@gmail.com>
parents:
87097
diff
changeset
|
892 goto error; |
|
61a712066770
Issue #19429, #19437: fix error handling in the OSError constructor
Victor Stinner <victor.stinner@gmail.com>
parents:
87097
diff
changeset
|
893 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
894 if (oserror_parse_args(&args, &myerrno, &strerror, &filename |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
895 #ifdef MS_WINDOWS |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
896 , &winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
897 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
898 )) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
899 goto error; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
900 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
901 if (myerrno && PyLong_Check(myerrno) && |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
902 errnomap && (PyObject *) type == PyExc_OSError) { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
903 PyObject *newtype; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
904 newtype = PyDict_GetItem(errnomap, myerrno); |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
905 if (newtype) { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
906 assert(PyType_Check(newtype)); |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
907 type = (PyTypeObject *) newtype; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
908 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
909 else if (PyErr_Occurred()) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
910 goto error; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
911 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
912 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
913 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
914 self = (PyOSErrorObject *) type->tp_alloc(type, 0); |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
915 if (!self) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
916 goto error; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
917 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
918 self->dict = NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
919 self->traceback = self->cause = self->context = NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
920 self->written = -1; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
921 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
922 if (!oserror_use_init(type)) { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
923 if (oserror_init(self, &args, myerrno, strerror, filename |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
924 #ifdef MS_WINDOWS |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
925 , winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
926 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
927 )) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
928 goto error; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
929 } |
|
77894
1cbab581bf1e
Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents:
77476
diff
changeset
|
930 else { |
|
1cbab581bf1e
Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents:
77476
diff
changeset
|
931 self->args = PyTuple_New(0); |
|
1cbab581bf1e
Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents:
77476
diff
changeset
|
932 if (self->args == NULL) |
|
1cbab581bf1e
Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents:
77476
diff
changeset
|
933 goto error; |
|
1cbab581bf1e
Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents:
77476
diff
changeset
|
934 } |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
935 |
|
87106
61a712066770
Issue #19429, #19437: fix error handling in the OSError constructor
Victor Stinner <victor.stinner@gmail.com>
parents:
87097
diff
changeset
|
936 Py_XDECREF(args); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
937 return (PyObject *) self; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
938 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
939 error: |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
940 Py_XDECREF(args); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
941 Py_XDECREF(self); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
942 return NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
943 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
944 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
945 static int |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
946 OSError_init(PyOSErrorObject *self, PyObject *args, PyObject *kwds) |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
947 { |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
948 PyObject *myerrno = NULL, *strerror = NULL, *filename = NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
949 #ifdef MS_WINDOWS |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
950 PyObject *winerror = NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
951 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
952 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
953 if (!oserror_use_init(Py_TYPE(self))) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
954 /* Everything already done in OSError_new */ |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
955 return 0; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
956 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
957 if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds)) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
958 return -1; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
959 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
960 Py_INCREF(args); |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
961 if (oserror_parse_args(&args, &myerrno, &strerror, &filename |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
962 #ifdef MS_WINDOWS |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
963 , &winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
964 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
965 )) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
966 goto error; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
967 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
968 if (oserror_init(self, &args, myerrno, strerror, filename |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
969 #ifdef MS_WINDOWS |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
970 , winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
971 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
972 )) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
973 goto error; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
974 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
975 return 0; |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
976 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
977 error: |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
978 Py_XDECREF(args); |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
979 return -1; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
980 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
981 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
982 static int |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
983 OSError_clear(PyOSErrorObject *self) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
984 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
985 Py_CLEAR(self->myerrno); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
986 Py_CLEAR(self->strerror); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
987 Py_CLEAR(self->filename); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
988 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
989 Py_CLEAR(self->winerror); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
990 #endif |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
991 return BaseException_clear((PyBaseExceptionObject *)self); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
992 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
993 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
994 static void |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
995 OSError_dealloc(PyOSErrorObject *self) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
996 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
997 _PyObject_GC_UNTRACK(self); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
998 OSError_clear(self); |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
999 Py_TYPE(self)->tp_free((PyObject *)self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1000 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1001 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1002 static int |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1003 OSError_traverse(PyOSErrorObject *self, visitproc visit, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1004 void *arg) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1005 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1006 Py_VISIT(self->myerrno); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1007 Py_VISIT(self->strerror); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1008 Py_VISIT(self->filename); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1009 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1010 Py_VISIT(self->winerror); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1011 #endif |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1012 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1013 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1014 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1015 static PyObject * |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1016 OSError_str(PyOSErrorObject *self) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1017 { |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1018 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1019 /* If available, winerror has the priority over myerrno */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1020 if (self->winerror && self->filename) |
|
78791
2e587b9bae35
Issue #15784: Modify OSError.__str__() to better distinguish between
Richard Oudkerk <shibturn@gmail.com>
parents:
78737
diff
changeset
|
1021 return PyUnicode_FromFormat("[WinError %S] %S: %R", |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1022 self->winerror ? self->winerror: Py_None, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1023 self->strerror ? self->strerror: Py_None, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1024 self->filename); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1025 if (self->winerror && self->strerror) |
|
78791
2e587b9bae35
Issue #15784: Modify OSError.__str__() to better distinguish between
Richard Oudkerk <shibturn@gmail.com>
parents:
78737
diff
changeset
|
1026 return PyUnicode_FromFormat("[WinError %S] %S", |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1027 self->winerror ? self->winerror: Py_None, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1028 self->strerror ? self->strerror: Py_None); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1029 #endif |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1030 if (self->filename) |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1031 return PyUnicode_FromFormat("[Errno %S] %S: %R", |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1032 self->myerrno ? self->myerrno: Py_None, |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1033 self->strerror ? self->strerror: Py_None, |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1034 self->filename); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1035 if (self->myerrno && self->strerror) |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1036 return PyUnicode_FromFormat("[Errno %S] %S", |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1037 self->myerrno ? self->myerrno: Py_None, |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1038 self->strerror ? self->strerror: Py_None); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1039 return BaseException_str((PyBaseExceptionObject *)self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1040 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1041 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1042 static PyObject * |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1043 OSError_reduce(PyOSErrorObject *self) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1044 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1045 PyObject *args = self->args; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1046 PyObject *res = NULL, *tmp; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1047 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1048 /* self->args is only the first two real arguments if there was a |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1049 * file name given to OSError. */ |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1050 if (PyTuple_GET_SIZE(args) == 2 && self->filename) { |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1051 args = PyTuple_New(3); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
1052 if (!args) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
1053 return NULL; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1054 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1055 tmp = PyTuple_GET_ITEM(self->args, 0); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1056 Py_INCREF(tmp); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1057 PyTuple_SET_ITEM(args, 0, tmp); |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1058 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1059 tmp = PyTuple_GET_ITEM(self->args, 1); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1060 Py_INCREF(tmp); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1061 PyTuple_SET_ITEM(args, 1, tmp); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1062 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1063 Py_INCREF(self->filename); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1064 PyTuple_SET_ITEM(args, 2, self->filename); |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1065 } else |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1066 Py_INCREF(args); |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1067 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1068 if (self->dict) |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
1069 res = PyTuple_Pack(3, Py_TYPE(self), args, self->dict); |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1070 else |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
1071 res = PyTuple_Pack(2, Py_TYPE(self), args); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1072 Py_DECREF(args); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1073 return res; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1074 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1075 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1076 static PyObject * |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1077 OSError_written_get(PyOSErrorObject *self, void *context) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1078 { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1079 if (self->written == -1) { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1080 PyErr_SetString(PyExc_AttributeError, "characters_written"); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1081 return NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1082 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1083 return PyLong_FromSsize_t(self->written); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1084 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1085 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1086 static int |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1087 OSError_written_set(PyOSErrorObject *self, PyObject *arg, void *context) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1088 { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1089 Py_ssize_t n; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1090 n = PyNumber_AsSsize_t(arg, PyExc_ValueError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1091 if (n == -1 && PyErr_Occurred()) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1092 return -1; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1093 self->written = n; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1094 return 0; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1095 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1096 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1097 static PyMemberDef OSError_members[] = { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1098 {"errno", T_OBJECT, offsetof(PyOSErrorObject, myerrno), 0, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1099 PyDoc_STR("POSIX exception code")}, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1100 {"strerror", T_OBJECT, offsetof(PyOSErrorObject, strerror), 0, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1101 PyDoc_STR("exception strerror")}, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1102 {"filename", T_OBJECT, offsetof(PyOSErrorObject, filename), 0, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1103 PyDoc_STR("exception filename")}, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1104 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1105 {"winerror", T_OBJECT, offsetof(PyOSErrorObject, winerror), 0, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1106 PyDoc_STR("Win32 exception code")}, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1107 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1108 {NULL} /* Sentinel */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1109 }; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1110 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1111 static PyMethodDef OSError_methods[] = { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1112 {"__reduce__", (PyCFunction)OSError_reduce, METH_NOARGS}, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1113 {NULL} |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1114 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1115 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1116 static PyGetSetDef OSError_getset[] = { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1117 {"characters_written", (getter) OSError_written_get, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1118 (setter) OSError_written_set, NULL}, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1119 {NULL} |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1120 }; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1121 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1122 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1123 ComplexExtendsException(PyExc_Exception, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1124 OSError, OSError_new, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1125 OSError_methods, OSError_members, OSError_getset, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1126 OSError_str, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1127 "Base class for I/O related errors."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1128 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1129 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1130 /* |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1131 * Various OSError subclasses |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1132 */ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1133 MiddlingExtendsException(PyExc_OSError, BlockingIOError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1134 "I/O operation would block."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1135 MiddlingExtendsException(PyExc_OSError, ConnectionError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1136 "Connection error."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1137 MiddlingExtendsException(PyExc_OSError, ChildProcessError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1138 "Child process error."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1139 MiddlingExtendsException(PyExc_ConnectionError, BrokenPipeError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1140 "Broken pipe."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1141 MiddlingExtendsException(PyExc_ConnectionError, ConnectionAbortedError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1142 "Connection aborted."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1143 MiddlingExtendsException(PyExc_ConnectionError, ConnectionRefusedError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1144 "Connection refused."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1145 MiddlingExtendsException(PyExc_ConnectionError, ConnectionResetError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1146 "Connection reset."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1147 MiddlingExtendsException(PyExc_OSError, FileExistsError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1148 "File already exists."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1149 MiddlingExtendsException(PyExc_OSError, FileNotFoundError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1150 "File not found."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1151 MiddlingExtendsException(PyExc_OSError, IsADirectoryError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1152 "Operation doesn't work on directories."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1153 MiddlingExtendsException(PyExc_OSError, NotADirectoryError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1154 "Operation only works on directories."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1155 MiddlingExtendsException(PyExc_OSError, InterruptedError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1156 "Interrupted by signal."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1157 MiddlingExtendsException(PyExc_OSError, PermissionError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1158 "Not enough permissions."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1159 MiddlingExtendsException(PyExc_OSError, ProcessLookupError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1160 "Process not found."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1161 MiddlingExtendsException(PyExc_OSError, TimeoutError, OSError, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1162 "Timeout expired."); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1163 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1164 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1165 * EOFError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1166 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1167 SimpleExtendsException(PyExc_Exception, EOFError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1168 "Read beyond end of file."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1169 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1170 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1171 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1172 * RuntimeError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1173 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1174 SimpleExtendsException(PyExc_Exception, RuntimeError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1175 "Unspecified run-time error."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1176 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1177 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1178 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1179 * NotImplementedError extends RuntimeError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1180 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1181 SimpleExtendsException(PyExc_RuntimeError, NotImplementedError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1182 "Method or function hasn't been implemented yet."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1183 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1184 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1185 * NameError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1186 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1187 SimpleExtendsException(PyExc_Exception, NameError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1188 "Name not found globally."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1189 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1190 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1191 * UnboundLocalError extends NameError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1192 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1193 SimpleExtendsException(PyExc_NameError, UnboundLocalError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1194 "Local name referenced but not bound to a value."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1195 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1196 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1197 * AttributeError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1198 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1199 SimpleExtendsException(PyExc_Exception, AttributeError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1200 "Attribute not found."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1201 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1202 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1203 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1204 * SyntaxError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1205 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1206 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1207 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1208 SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1209 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1210 PyObject *info = NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1211 Py_ssize_t lenargs = PyTuple_GET_SIZE(args); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1212 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1213 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1214 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1215 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1216 if (lenargs >= 1) { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1217 Py_CLEAR(self->msg); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1218 self->msg = PyTuple_GET_ITEM(args, 0); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1219 Py_INCREF(self->msg); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1220 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1221 if (lenargs == 2) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1222 info = PyTuple_GET_ITEM(args, 1); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1223 info = PySequence_Tuple(info); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
1224 if (!info) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
1225 return -1; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1226 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1227 if (PyTuple_GET_SIZE(info) != 4) { |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1228 /* not a very good error message, but it's what Python 2.4 gives */ |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1229 PyErr_SetString(PyExc_IndexError, "tuple index out of range"); |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1230 Py_DECREF(info); |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1231 return -1; |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1232 } |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1233 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1234 Py_CLEAR(self->filename); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1235 self->filename = PyTuple_GET_ITEM(info, 0); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1236 Py_INCREF(self->filename); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1237 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1238 Py_CLEAR(self->lineno); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1239 self->lineno = PyTuple_GET_ITEM(info, 1); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1240 Py_INCREF(self->lineno); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1241 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1242 Py_CLEAR(self->offset); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1243 self->offset = PyTuple_GET_ITEM(info, 2); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1244 Py_INCREF(self->offset); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1245 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1246 Py_CLEAR(self->text); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1247 self->text = PyTuple_GET_ITEM(info, 3); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1248 Py_INCREF(self->text); |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1249 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1250 Py_DECREF(info); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1251 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1252 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1253 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1254 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1255 static int |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1256 SyntaxError_clear(PySyntaxErrorObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1257 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1258 Py_CLEAR(self->msg); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1259 Py_CLEAR(self->filename); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1260 Py_CLEAR(self->lineno); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1261 Py_CLEAR(self->offset); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1262 Py_CLEAR(self->text); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1263 Py_CLEAR(self->print_file_and_line); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1264 return BaseException_clear((PyBaseExceptionObject *)self); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1265 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1266 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1267 static void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1268 SyntaxError_dealloc(PySyntaxErrorObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1269 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
1270 _PyObject_GC_UNTRACK(self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1271 SyntaxError_clear(self); |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
1272 Py_TYPE(self)->tp_free((PyObject *)self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1273 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1274 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1275 static int |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1276 SyntaxError_traverse(PySyntaxErrorObject *self, visitproc visit, void *arg) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1277 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1278 Py_VISIT(self->msg); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1279 Py_VISIT(self->filename); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1280 Py_VISIT(self->lineno); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1281 Py_VISIT(self->offset); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1282 Py_VISIT(self->text); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1283 Py_VISIT(self->print_file_and_line); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1284 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1285 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1286 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1287 /* This is called "my_basename" instead of just "basename" to avoid name |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1288 conflicts with glibc; basename is already prototyped if _GNU_SOURCE is |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1289 defined, and Python does define that. */ |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1290 static PyObject* |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1291 my_basename(PyObject *name) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1292 { |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1293 Py_ssize_t i, size, offset; |
|
72703
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1294 int kind; |
|
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1295 void *data; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1296 |
|
72703
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1297 if (PyUnicode_READY(name)) |
|
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1298 return NULL; |
|
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1299 kind = PyUnicode_KIND(name); |
|
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1300 data = PyUnicode_DATA(name); |
| 72475 | 1301 size = PyUnicode_GET_LENGTH(name); |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1302 offset = 0; |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1303 for(i=0; i < size; i++) { |
| 72475 | 1304 if (PyUnicode_READ(kind, data, i) == SEP) |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1305 offset = i + 1; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1306 } |
| 72475 | 1307 if (offset != 0) |
| 1308 return PyUnicode_Substring(name, offset, size); | |
| 1309 else { | |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1310 Py_INCREF(name); |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1311 return name; |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1312 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1313 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1314 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1315 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1316 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1317 SyntaxError_str(PySyntaxErrorObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1318 { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1319 int have_lineno = 0; |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1320 PyObject *filename; |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1321 PyObject *result; |
|
44158
81e0c0e2a8c1
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents:
44129
diff
changeset
|
1322 /* Below, we always ignore overflow errors, just printing -1. |
|
81e0c0e2a8c1
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents:
44129
diff
changeset
|
1323 Still, we cannot allow an OverflowError to be raised, so |
|
81e0c0e2a8c1
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents:
44129
diff
changeset
|
1324 we need to call PyLong_AsLongAndOverflow. */ |
|
81e0c0e2a8c1
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents:
44129
diff
changeset
|
1325 int overflow; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1326 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1327 /* XXX -- do all the additional formatting with filename and |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1328 lineno here */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1329 |
|
42855
d5b52d56beba
Use unicode and remove support for some uses of str8.
Neal Norwitz <nnorwitz@gmail.com>
parents:
42669
diff
changeset
|
1330 if (self->filename && PyUnicode_Check(self->filename)) { |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1331 filename = my_basename(self->filename); |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1332 if (filename == NULL) |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1333 return NULL; |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1334 } else { |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1335 filename = NULL; |
|
42305
d0719406b2c6
Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents:
42118
diff
changeset
|
1336 } |
|
44158
81e0c0e2a8c1
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents:
44129
diff
changeset
|
1337 have_lineno = (self->lineno != NULL) && PyLong_CheckExact(self->lineno); |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1338 |
|
42305
d0719406b2c6
Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents:
42118
diff
changeset
|
1339 if (!filename && !have_lineno) |
|
43866
8ed0280c2ab6
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
Thomas Heller <theller@ctypes.org>
parents:
43777
diff
changeset
|
1340 return PyObject_Str(self->msg ? self->msg : Py_None); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1341 |
|
42305
d0719406b2c6
Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents:
42118
diff
changeset
|
1342 if (filename && have_lineno) |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1343 result = PyUnicode_FromFormat("%S (%U, line %ld)", |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1344 self->msg ? self->msg : Py_None, |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1345 filename, |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59128
diff
changeset
|
1346 PyLong_AsLongAndOverflow(self->lineno, &overflow)); |
|
42305
d0719406b2c6
Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents:
42118
diff
changeset
|
1347 else if (filename) |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1348 result = PyUnicode_FromFormat("%S (%U)", |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1349 self->msg ? self->msg : Py_None, |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1350 filename); |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1351 else /* only have_lineno */ |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1352 result = PyUnicode_FromFormat("%S (line %ld)", |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1353 self->msg ? self->msg : Py_None, |
|
44158
81e0c0e2a8c1
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents:
44129
diff
changeset
|
1354 PyLong_AsLongAndOverflow(self->lineno, &overflow)); |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1355 Py_XDECREF(filename); |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1356 return result; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1357 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1358 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1359 static PyMemberDef SyntaxError_members[] = { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1360 {"msg", T_OBJECT, offsetof(PySyntaxErrorObject, msg), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1361 PyDoc_STR("exception msg")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1362 {"filename", T_OBJECT, offsetof(PySyntaxErrorObject, filename), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1363 PyDoc_STR("exception filename")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1364 {"lineno", T_OBJECT, offsetof(PySyntaxErrorObject, lineno), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1365 PyDoc_STR("exception lineno")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1366 {"offset", T_OBJECT, offsetof(PySyntaxErrorObject, offset), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1367 PyDoc_STR("exception offset")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1368 {"text", T_OBJECT, offsetof(PySyntaxErrorObject, text), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1369 PyDoc_STR("exception text")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1370 {"print_file_and_line", T_OBJECT, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1371 offsetof(PySyntaxErrorObject, print_file_and_line), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1372 PyDoc_STR("exception print_file_and_line")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1373 {NULL} /* Sentinel */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1374 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1375 |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1376 ComplexExtendsException(PyExc_Exception, SyntaxError, SyntaxError, |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1377 0, 0, SyntaxError_members, 0, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1378 SyntaxError_str, "Invalid syntax."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1379 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1380 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1381 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1382 * IndentationError extends SyntaxError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1383 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1384 MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1385 "Improper indentation."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1386 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1387 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1388 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1389 * TabError extends IndentationError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1390 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1391 MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1392 "Improper mixture of spaces and tabs."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1393 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1394 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1395 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1396 * LookupError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1397 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1398 SimpleExtendsException(PyExc_Exception, LookupError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1399 "Base class for lookup errors."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1400 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1401 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1402 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1403 * IndexError extends LookupError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1404 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1405 SimpleExtendsException(PyExc_LookupError, IndexError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1406 "Sequence index out of range."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1407 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1408 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1409 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1410 * KeyError extends LookupError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1411 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1412 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1413 KeyError_str(PyBaseExceptionObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1414 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1415 /* If args is a tuple of exactly one item, apply repr to args[0]. |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1416 This is done so that e.g. the exception raised by {}[''] prints |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1417 KeyError: '' |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1418 rather than the confusing |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1419 KeyError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1420 alone. The downside is that if KeyError is raised with an explanatory |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1421 string, that string will be displayed in quotes. Too bad. |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1422 If args is anything else, use the default BaseException__str__(). |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1423 */ |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1424 if (PyTuple_GET_SIZE(self->args) == 1) { |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1425 return PyObject_Repr(PyTuple_GET_ITEM(self->args, 0)); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1426 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1427 return BaseException_str(self); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1428 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1429 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1430 ComplexExtendsException(PyExc_LookupError, KeyError, BaseException, |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1431 0, 0, 0, 0, KeyError_str, "Mapping key not found."); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1432 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1433 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1434 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1435 * ValueError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1436 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1437 SimpleExtendsException(PyExc_Exception, ValueError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1438 "Inappropriate argument value (of correct type)."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1439 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1440 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1441 * UnicodeError extends ValueError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1442 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1443 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1444 SimpleExtendsException(PyExc_ValueError, UnicodeError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1445 "Unicode related error."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1446 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1447 static PyObject * |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1448 get_string(PyObject *attr, const char *name) |
|
41611
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1449 { |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1450 if (!attr) { |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1451 PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1452 return NULL; |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1453 } |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1454 |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1455 if (!PyBytes_Check(attr)) { |
|
41611
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1456 PyErr_Format(PyExc_TypeError, "%.200s attribute must be bytes", name); |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1457 return NULL; |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1458 } |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1459 Py_INCREF(attr); |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1460 return attr; |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1461 } |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1462 |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1463 static PyObject * |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1464 get_unicode(PyObject *attr, const char *name) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1465 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1466 if (!attr) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1467 PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1468 return NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1469 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1470 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1471 if (!PyUnicode_Check(attr)) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1472 PyErr_Format(PyExc_TypeError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1473 "%.200s attribute must be unicode", name); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1474 return NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1475 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1476 Py_INCREF(attr); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1477 return attr; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1478 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1479 |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1480 static int |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1481 set_unicodefromstring(PyObject **attr, const char *value) |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1482 { |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1483 PyObject *obj = PyUnicode_FromString(value); |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1484 if (!obj) |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1485 return -1; |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1486 Py_CLEAR(*attr); |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1487 *attr = obj; |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1488 return 0; |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1489 } |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1490 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1491 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1492 PyUnicodeEncodeError_GetEncoding(PyObject *exc) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1493 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1494 return get_unicode(((PyUnicodeErrorObject *)exc)->encoding, "encoding"); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1495 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1496 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1497 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1498 PyUnicodeDecodeError_GetEncoding(PyObject *exc) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1499 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1500 return get_unicode(((PyUnicodeErrorObject *)exc)->encoding, "encoding"); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1501 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1502 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1503 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1504 PyUnicodeEncodeError_GetObject(PyObject *exc) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1505 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1506 return get_unicode(((PyUnicodeErrorObject *)exc)->object, "object"); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1507 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1508 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1509 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1510 PyUnicodeDecodeError_GetObject(PyObject *exc) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1511 { |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1512 return get_string(((PyUnicodeErrorObject *)exc)->object, "object"); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1513 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1514 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1515 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1516 PyUnicodeTranslateError_GetObject(PyObject *exc) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1517 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1518 return get_unicode(((PyUnicodeErrorObject *)exc)->object, "object"); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1519 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1520 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1521 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1522 PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1523 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1524 Py_ssize_t size; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1525 PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1526 "object"); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1527 if (!obj) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1528 return -1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1529 *start = ((PyUnicodeErrorObject *)exc)->start; |
|
73655
2e37fc70e2dd
Fix misuse of PyUnicode_GET_SIZE() => PyUnicode_GET_LENGTH()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73649
diff
changeset
|
1530 size = PyUnicode_GET_LENGTH(obj); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1531 if (*start<0) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1532 *start = 0; /*XXX check for values <0*/ |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1533 if (*start>=size) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1534 *start = size-1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1535 Py_DECREF(obj); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1536 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1537 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1538 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1539 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1540 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1541 PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1542 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1543 Py_ssize_t size; |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1544 PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object"); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1545 if (!obj) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1546 return -1; |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1547 size = PyBytes_GET_SIZE(obj); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1548 *start = ((PyUnicodeErrorObject *)exc)->start; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1549 if (*start<0) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1550 *start = 0; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1551 if (*start>=size) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1552 *start = size-1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1553 Py_DECREF(obj); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1554 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1555 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1556 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1557 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1558 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1559 PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1560 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1561 return PyUnicodeEncodeError_GetStart(exc, start); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1562 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1563 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1564 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1565 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1566 PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1567 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1568 ((PyUnicodeErrorObject *)exc)->start = start; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1569 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1570 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1571 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1572 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1573 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1574 PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1575 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1576 ((PyUnicodeErrorObject *)exc)->start = start; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1577 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1578 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1579 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1580 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1581 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1582 PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1583 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1584 ((PyUnicodeErrorObject *)exc)->start = start; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1585 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1586 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1587 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1588 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1589 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1590 PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1591 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1592 Py_ssize_t size; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1593 PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1594 "object"); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1595 if (!obj) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1596 return -1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1597 *end = ((PyUnicodeErrorObject *)exc)->end; |
|
73655
2e37fc70e2dd
Fix misuse of PyUnicode_GET_SIZE() => PyUnicode_GET_LENGTH()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73649
diff
changeset
|
1598 size = PyUnicode_GET_LENGTH(obj); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1599 if (*end<1) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1600 *end = 1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1601 if (*end>size) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1602 *end = size; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1603 Py_DECREF(obj); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1604 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1605 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1606 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1607 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1608 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1609 PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1610 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1611 Py_ssize_t size; |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1612 PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object"); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1613 if (!obj) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1614 return -1; |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1615 size = PyBytes_GET_SIZE(obj); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1616 *end = ((PyUnicodeErrorObject *)exc)->end; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1617 if (*end<1) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1618 *end = 1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1619 if (*end>size) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1620 *end = size; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1621 Py_DECREF(obj); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1622 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1623 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1624 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1625 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1626 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1627 PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *start) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1628 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1629 return PyUnicodeEncodeError_GetEnd(exc, start); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1630 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1631 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1632 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1633 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1634 PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1635 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1636 ((PyUnicodeErrorObject *)exc)->end = end; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1637 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1638 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1639 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1640 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1641 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1642 PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1643 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1644 ((PyUnicodeErrorObject *)exc)->end = end; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1645 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1646 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1647 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1648 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1649 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1650 PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1651 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1652 ((PyUnicodeErrorObject *)exc)->end = end; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1653 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1654 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1655 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1656 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1657 PyUnicodeEncodeError_GetReason(PyObject *exc) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1658 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1659 return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason"); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1660 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1661 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1662 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1663 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1664 PyUnicodeDecodeError_GetReason(PyObject *exc) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1665 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1666 return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason"); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1667 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1668 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1669 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1670 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1671 PyUnicodeTranslateError_GetReason(PyObject *exc) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1672 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1673 return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason"); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1674 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1675 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1676 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1677 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1678 PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1679 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1680 return set_unicodefromstring(&((PyUnicodeErrorObject *)exc)->reason, |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1681 reason); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1682 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1683 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1684 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1685 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1686 PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1687 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1688 return set_unicodefromstring(&((PyUnicodeErrorObject *)exc)->reason, |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1689 reason); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1690 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1691 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1692 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1693 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1694 PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1695 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1696 return set_unicodefromstring(&((PyUnicodeErrorObject *)exc)->reason, |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1697 reason); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1698 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1699 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1700 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1701 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1702 UnicodeError_clear(PyUnicodeErrorObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1703 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1704 Py_CLEAR(self->encoding); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1705 Py_CLEAR(self->object); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1706 Py_CLEAR(self->reason); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1707 return BaseException_clear((PyBaseExceptionObject *)self); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1708 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1709 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1710 static void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1711 UnicodeError_dealloc(PyUnicodeErrorObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1712 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
1713 _PyObject_GC_UNTRACK(self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1714 UnicodeError_clear(self); |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44158
diff
changeset
|
1715 Py_TYPE(self)->tp_free((PyObject *)self); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1716 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1717 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1718 static int |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1719 UnicodeError_traverse(PyUnicodeErrorObject *self, visitproc visit, void *arg) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1720 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1721 Py_VISIT(self->encoding); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1722 Py_VISIT(self->object); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1723 Py_VISIT(self->reason); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1724 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1725 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1726 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1727 static PyMemberDef UnicodeError_members[] = { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1728 {"encoding", T_OBJECT, offsetof(PyUnicodeErrorObject, encoding), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1729 PyDoc_STR("exception encoding")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1730 {"object", T_OBJECT, offsetof(PyUnicodeErrorObject, object), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1731 PyDoc_STR("exception object")}, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1732 {"start", T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), 0, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1733 PyDoc_STR("exception start")}, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1734 {"end", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1735 PyDoc_STR("exception end")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1736 {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1737 PyDoc_STR("exception reason")}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1738 {NULL} /* Sentinel */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1739 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1740 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1741 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1742 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1743 * UnicodeEncodeError extends UnicodeError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1744 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1745 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1746 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1747 UnicodeEncodeError_init(PyObject *self, PyObject *args, PyObject *kwds) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1748 { |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1749 PyUnicodeErrorObject *err; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1750 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1751 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1752 return -1; |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1753 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1754 err = (PyUnicodeErrorObject *)self; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1755 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1756 Py_CLEAR(err->encoding); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1757 Py_CLEAR(err->object); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1758 Py_CLEAR(err->reason); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1759 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1760 if (!PyArg_ParseTuple(args, "O!O!nnO!", |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1761 &PyUnicode_Type, &err->encoding, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1762 &PyUnicode_Type, &err->object, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1763 &err->start, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1764 &err->end, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1765 &PyUnicode_Type, &err->reason)) { |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1766 err->encoding = err->object = err->reason = NULL; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1767 return -1; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1768 } |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1769 |
|
73350
0883d6a103a0
Port error handlers from Py_UNICODE indexing to code point indexing.
Martin v. Löwis <martin@v.loewis.de>
parents:
72879
diff
changeset
|
1770 if (PyUnicode_READY(err->object) < -1) { |
|
0883d6a103a0
Port error handlers from Py_UNICODE indexing to code point indexing.
Martin v. Löwis <martin@v.loewis.de>
parents:
72879
diff
changeset
|
1771 err->encoding = NULL; |
|
0883d6a103a0
Port error handlers from Py_UNICODE indexing to code point indexing.
Martin v. Löwis <martin@v.loewis.de>
parents:
72879
diff
changeset
|
1772 return -1; |
|
0883d6a103a0
Port error handlers from Py_UNICODE indexing to code point indexing.
Martin v. Löwis <martin@v.loewis.de>
parents:
72879
diff
changeset
|
1773 } |
|
0883d6a103a0
Port error handlers from Py_UNICODE indexing to code point indexing.
Martin v. Löwis <martin@v.loewis.de>
parents:
72879
diff
changeset
|
1774 |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1775 Py_INCREF(err->encoding); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1776 Py_INCREF(err->object); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1777 Py_INCREF(err->reason); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1778 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1779 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1780 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1781 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1782 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1783 UnicodeEncodeError_str(PyObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1784 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1785 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1786 PyObject *result = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1787 PyObject *reason_str = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1788 PyObject *encoding_str = NULL; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1789 |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1790 /* Get reason and encoding as strings, which they might not be if |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1791 they've been modified after we were contructed. */ |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1792 reason_str = PyObject_Str(uself->reason); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1793 if (reason_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1794 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1795 encoding_str = PyObject_Str(uself->encoding); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1796 if (encoding_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1797 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1798 |
|
73644
5b426bf9260c
UnicodeEncodeError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73350
diff
changeset
|
1799 if (uself->start < PyUnicode_GET_LENGTH(uself->object) && uself->end == uself->start+1) { |
|
5b426bf9260c
UnicodeEncodeError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73350
diff
changeset
|
1800 Py_UCS4 badchar = PyUnicode_ReadChar(uself->object, uself->start); |
|
41940
5014f8daa57f
PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents:
41882
diff
changeset
|
1801 const char *fmt; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1802 if (badchar <= 0xff) |
|
42118
70a0831feda6
Patch by Ron Adam: Don't use u prefix in unicode error messages
Walter Dörwald <walter@livinglogic.de>
parents:
42110
diff
changeset
|
1803 fmt = "'%U' codec can't encode character '\\x%02x' in position %zd: %U"; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1804 else if (badchar <= 0xffff) |
|
42118
70a0831feda6
Patch by Ron Adam: Don't use u prefix in unicode error messages
Walter Dörwald <walter@livinglogic.de>
parents:
42110
diff
changeset
|
1805 fmt = "'%U' codec can't encode character '\\u%04x' in position %zd: %U"; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1806 else |
|
42118
70a0831feda6
Patch by Ron Adam: Don't use u prefix in unicode error messages
Walter Dörwald <walter@livinglogic.de>
parents:
42110
diff
changeset
|
1807 fmt = "'%U' codec can't encode character '\\U%08x' in position %zd: %U"; |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1808 result = PyUnicode_FromFormat( |
|
41940
5014f8daa57f
PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents:
41882
diff
changeset
|
1809 fmt, |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1810 encoding_str, |
|
73644
5b426bf9260c
UnicodeEncodeError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73350
diff
changeset
|
1811 (int)badchar, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1812 uself->start, |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1813 reason_str); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1814 } |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1815 else { |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1816 result = PyUnicode_FromFormat( |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1817 "'%U' codec can't encode characters in position %zd-%zd: %U", |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1818 encoding_str, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1819 uself->start, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1820 uself->end-1, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1821 reason_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1822 } |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1823 done: |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1824 Py_XDECREF(reason_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1825 Py_XDECREF(encoding_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1826 return result; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1827 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1828 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1829 static PyTypeObject _PyExc_UnicodeEncodeError = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42305
diff
changeset
|
1830 PyVarObject_HEAD_INIT(NULL, 0) |
|
40949
e759fd8d95ae
Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents:
40909
diff
changeset
|
1831 "UnicodeEncodeError", |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1832 sizeof(PyUnicodeErrorObject), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1833 (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1834 (reprfunc)UnicodeEncodeError_str, 0, 0, 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1835 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1836 PyDoc_STR("Unicode encoding error."), (traverseproc)UnicodeError_traverse, |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1837 (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1838 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1839 (initproc)UnicodeEncodeError_init, 0, BaseException_new, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1840 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1841 PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1842 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1843 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1844 PyUnicodeEncodeError_Create( |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1845 const char *encoding, const Py_UNICODE *object, Py_ssize_t length, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1846 Py_ssize_t start, Py_ssize_t end, const char *reason) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1847 { |
|
62155
600c23127207
Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
Victor Stinner <victor.stinner@haypocalc.com>
parents:
61466
diff
changeset
|
1848 return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns", |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1849 encoding, object, length, start, end, reason); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1850 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1851 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1852 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1853 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1854 * UnicodeDecodeError extends UnicodeError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1855 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1856 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1857 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1858 UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1859 { |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1860 PyUnicodeErrorObject *ude; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1861 const char *data; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1862 Py_ssize_t size; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1863 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1864 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1865 return -1; |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1866 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1867 ude = (PyUnicodeErrorObject *)self; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1868 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1869 Py_CLEAR(ude->encoding); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1870 Py_CLEAR(ude->object); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1871 Py_CLEAR(ude->reason); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1872 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1873 if (!PyArg_ParseTuple(args, "O!OnnO!", |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1874 &PyUnicode_Type, &ude->encoding, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1875 &ude->object, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1876 &ude->start, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1877 &ude->end, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1878 &PyUnicode_Type, &ude->reason)) { |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1879 ude->encoding = ude->object = ude->reason = NULL; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1880 return -1; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1881 } |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1882 |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1883 if (!PyBytes_Check(ude->object)) { |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1884 if (PyObject_AsReadBuffer(ude->object, (const void **)&data, &size)) { |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1885 ude->encoding = ude->object = ude->reason = NULL; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1886 return -1; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1887 } |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1888 ude->object = PyBytes_FromStringAndSize(data, size); |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1889 } |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1890 else { |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1891 Py_INCREF(ude->object); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1892 } |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1893 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1894 Py_INCREF(ude->encoding); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1895 Py_INCREF(ude->reason); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1896 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1897 return 0; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1898 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1899 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1900 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1901 UnicodeDecodeError_str(PyObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1902 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1903 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1904 PyObject *result = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1905 PyObject *reason_str = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1906 PyObject *encoding_str = NULL; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1907 |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1908 /* Get reason and encoding as strings, which they might not be if |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1909 they've been modified after we were contructed. */ |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1910 reason_str = PyObject_Str(uself->reason); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1911 if (reason_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1912 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1913 encoding_str = PyObject_Str(uself->encoding); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1914 if (encoding_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1915 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1916 |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1917 if (uself->start < PyBytes_GET_SIZE(uself->object) && uself->end == uself->start+1) { |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1918 int byte = (int)(PyBytes_AS_STRING(((PyUnicodeErrorObject *)self)->object)[uself->start]&0xff); |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1919 result = PyUnicode_FromFormat( |
|
41940
5014f8daa57f
PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents:
41882
diff
changeset
|
1920 "'%U' codec can't decode byte 0x%02x in position %zd: %U", |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1921 encoding_str, |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1922 byte, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1923 uself->start, |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1924 reason_str); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1925 } |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1926 else { |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1927 result = PyUnicode_FromFormat( |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1928 "'%U' codec can't decode bytes in position %zd-%zd: %U", |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1929 encoding_str, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1930 uself->start, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1931 uself->end-1, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1932 reason_str |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1933 ); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1934 } |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1935 done: |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1936 Py_XDECREF(reason_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1937 Py_XDECREF(encoding_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1938 return result; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1939 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1940 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1941 static PyTypeObject _PyExc_UnicodeDecodeError = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42305
diff
changeset
|
1942 PyVarObject_HEAD_INIT(NULL, 0) |
|
40949
e759fd8d95ae
Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents:
40909
diff
changeset
|
1943 "UnicodeDecodeError", |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1944 sizeof(PyUnicodeErrorObject), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1945 (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1946 (reprfunc)UnicodeDecodeError_str, 0, 0, 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1947 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1948 PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1949 (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1950 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1951 (initproc)UnicodeDecodeError_init, 0, BaseException_new, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1952 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1953 PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1954 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1955 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1956 PyUnicodeDecodeError_Create( |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1957 const char *encoding, const char *object, Py_ssize_t length, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1958 Py_ssize_t start, Py_ssize_t end, const char *reason) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1959 { |
|
62155
600c23127207
Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
Victor Stinner <victor.stinner@haypocalc.com>
parents:
61466
diff
changeset
|
1960 return PyObject_CallFunction(PyExc_UnicodeDecodeError, "sy#nns", |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1961 encoding, object, length, start, end, reason); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1962 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1963 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1964 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1965 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1966 * UnicodeTranslateError extends UnicodeError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1967 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1968 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1969 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1970 UnicodeTranslateError_init(PyUnicodeErrorObject *self, PyObject *args, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1971 PyObject *kwds) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1972 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1973 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1974 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1975 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1976 Py_CLEAR(self->object); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1977 Py_CLEAR(self->reason); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1978 |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1979 if (!PyArg_ParseTuple(args, "O!nnO!", |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1980 &PyUnicode_Type, &self->object, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1981 &self->start, |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1982 &self->end, |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1983 &PyUnicode_Type, &self->reason)) { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1984 self->object = self->reason = NULL; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1985 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1986 } |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1987 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1988 Py_INCREF(self->object); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1989 Py_INCREF(self->reason); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1990 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1991 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1992 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1993 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1994 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1995 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1996 UnicodeTranslateError_str(PyObject *self) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1997 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1998 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1999 PyObject *result = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2000 PyObject *reason_str = NULL; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2001 |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2002 /* Get reason as a string, which it might not be if it's been |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2003 modified after we were contructed. */ |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2004 reason_str = PyObject_Str(uself->reason); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2005 if (reason_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2006 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2007 |
|
73649
244d9159aa38
UnicodeTranslateError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73644
diff
changeset
|
2008 if (uself->start < PyUnicode_GET_LENGTH(uself->object) && uself->end == uself->start+1) { |
|
244d9159aa38
UnicodeTranslateError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73644
diff
changeset
|
2009 Py_UCS4 badchar = PyUnicode_ReadChar(uself->object, uself->start); |
|
41940
5014f8daa57f
PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents:
41882
diff
changeset
|
2010 const char *fmt; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2011 if (badchar <= 0xff) |
|
42118
70a0831feda6
Patch by Ron Adam: Don't use u prefix in unicode error messages
Walter Dörwald <walter@livinglogic.de>
parents:
42110
diff
changeset
|
2012 fmt = "can't translate character '\\x%02x' in position %zd: %U"; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2013 else if (badchar <= 0xffff) |
|
42118
70a0831feda6
Patch by Ron Adam: Don't use u prefix in unicode error messages
Walter Dörwald <walter@livinglogic.de>
parents:
42110
diff
changeset
|
2014 fmt = "can't translate character '\\u%04x' in position %zd: %U"; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2015 else |
|
42118
70a0831feda6
Patch by Ron Adam: Don't use u prefix in unicode error messages
Walter Dörwald <walter@livinglogic.de>
parents:
42110
diff
changeset
|
2016 fmt = "can't translate character '\\U%08x' in position %zd: %U"; |
|
59128
f5ea1264b7ae
Merged revisions 78437 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
59111
diff
changeset
|
2017 result = PyUnicode_FromFormat( |
|
41940
5014f8daa57f
PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents:
41882
diff
changeset
|
2018 fmt, |
|
73649
244d9159aa38
UnicodeTranslateError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73644
diff
changeset
|
2019 (int)badchar, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
2020 uself->start, |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2021 reason_str |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2022 ); |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2023 } else { |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2024 result = PyUnicode_FromFormat( |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2025 "can't translate characters in position %zd-%zd: %U", |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2026 uself->start, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2027 uself->end-1, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2028 reason_str |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2029 ); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2030 } |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2031 done: |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2032 Py_XDECREF(reason_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2033 return result; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2034 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2035 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2036 static PyTypeObject _PyExc_UnicodeTranslateError = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42305
diff
changeset
|
2037 PyVarObject_HEAD_INIT(NULL, 0) |
|
40949
e759fd8d95ae
Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents:
40909
diff
changeset
|
2038 "UnicodeTranslateError", |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2039 sizeof(PyUnicodeErrorObject), 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2040 (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2041 (reprfunc)UnicodeTranslateError_str, 0, 0, 0, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2042 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
2043 PyDoc_STR("Unicode translation error."), (traverseproc)UnicodeError_traverse, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2044 (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2045 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2046 (initproc)UnicodeTranslateError_init, 0, BaseException_new, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2047 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2048 PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2049 |
| 72475 | 2050 /* Deprecated. */ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2051 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2052 PyUnicodeTranslateError_Create( |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2053 const Py_UNICODE *object, Py_ssize_t length, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2054 Py_ssize_t start, Py_ssize_t end, const char *reason) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2055 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2056 return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns", |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2057 object, length, start, end, reason); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2058 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2059 |
| 72475 | 2060 PyObject * |
| 2061 _PyUnicodeTranslateError_Create( | |
| 2062 PyObject *object, | |
| 2063 Py_ssize_t start, Py_ssize_t end, const char *reason) | |
| 2064 { | |
| 2065 return PyObject_CallFunction(PyExc_UnicodeTranslateError, "Ons", | |
| 2066 object, start, end, reason); | |
| 2067 } | |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2068 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2069 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2070 * AssertionError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2071 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2072 SimpleExtendsException(PyExc_Exception, AssertionError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2073 "Assertion failed."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2074 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2075 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2076 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2077 * ArithmeticError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2078 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2079 SimpleExtendsException(PyExc_Exception, ArithmeticError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2080 "Base class for arithmetic errors."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2081 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2082 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2083 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2084 * FloatingPointError extends ArithmeticError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2085 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2086 SimpleExtendsException(PyExc_ArithmeticError, FloatingPointError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2087 "Floating point operation failed."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2088 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2089 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2090 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2091 * OverflowError extends ArithmeticError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2092 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2093 SimpleExtendsException(PyExc_ArithmeticError, OverflowError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2094 "Result too large to be represented."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2095 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2096 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2097 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2098 * ZeroDivisionError extends ArithmeticError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2099 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2100 SimpleExtendsException(PyExc_ArithmeticError, ZeroDivisionError, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2101 "Second argument to a division or modulo operation was zero."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2102 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2103 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2104 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2105 * SystemError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2106 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2107 SimpleExtendsException(PyExc_Exception, SystemError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2108 "Internal error in the Python interpreter.\n" |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2109 "\n" |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2110 "Please report this to the Python maintainer, along with the traceback,\n" |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2111 "the Python version, and the hardware/OS platform and version."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2112 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2113 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2114 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2115 * ReferenceError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2116 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2117 SimpleExtendsException(PyExc_Exception, ReferenceError, |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2118 "Weak ref proxy used after referent went away."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2119 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2120 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2121 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2122 * MemoryError extends Exception |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2123 */ |
|
65690
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2124 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2125 #define MEMERRORS_SAVE 16 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2126 static PyBaseExceptionObject *memerrors_freelist = NULL; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2127 static int memerrors_numfree = 0; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2128 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2129 static PyObject * |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2130 MemoryError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2131 { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2132 PyBaseExceptionObject *self; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2133 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2134 if (type != (PyTypeObject *) PyExc_MemoryError) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2135 return BaseException_new(type, args, kwds); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2136 if (memerrors_freelist == NULL) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2137 return BaseException_new(type, args, kwds); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2138 /* Fetch object from freelist and revive it */ |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2139 self = memerrors_freelist; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2140 self->args = PyTuple_New(0); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2141 /* This shouldn't happen since the empty tuple is persistent */ |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2142 if (self->args == NULL) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2143 return NULL; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2144 memerrors_freelist = (PyBaseExceptionObject *) self->dict; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2145 memerrors_numfree--; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2146 self->dict = NULL; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2147 _Py_NewReference((PyObject *)self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2148 _PyObject_GC_TRACK(self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2149 return (PyObject *)self; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2150 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2151 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2152 static void |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2153 MemoryError_dealloc(PyBaseExceptionObject *self) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2154 { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2155 _PyObject_GC_UNTRACK(self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2156 BaseException_clear(self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2157 if (memerrors_numfree >= MEMERRORS_SAVE) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2158 Py_TYPE(self)->tp_free((PyObject *)self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2159 else { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2160 self->dict = (PyObject *) memerrors_freelist; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2161 memerrors_freelist = self; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2162 memerrors_numfree++; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2163 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2164 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2165 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2166 static void |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2167 preallocate_memerrors(void) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2168 { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2169 /* We create enough MemoryErrors and then decref them, which will fill |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2170 up the freelist. */ |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2171 int i; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2172 PyObject *errors[MEMERRORS_SAVE]; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2173 for (i = 0; i < MEMERRORS_SAVE; i++) { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2174 errors[i] = MemoryError_new((PyTypeObject *) PyExc_MemoryError, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2175 NULL, NULL); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2176 if (!errors[i]) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2177 Py_FatalError("Could not preallocate MemoryError object"); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2178 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2179 for (i = 0; i < MEMERRORS_SAVE; i++) { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2180 Py_DECREF(errors[i]); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2181 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2182 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2183 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2184 static void |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2185 free_preallocated_memerrors(void) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2186 { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2187 while (memerrors_freelist != NULL) { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2188 PyObject *self = (PyObject *) memerrors_freelist; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2189 memerrors_freelist = (PyBaseExceptionObject *) memerrors_freelist->dict; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2190 Py_TYPE(self)->tp_free((PyObject *)self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2191 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2192 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2193 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2194 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2195 static PyTypeObject _PyExc_MemoryError = { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2196 PyVarObject_HEAD_INIT(NULL, 0) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2197 "MemoryError", |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2198 sizeof(PyBaseExceptionObject), |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2199 0, (destructor)MemoryError_dealloc, 0, 0, 0, 0, 0, 0, 0, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2200 0, 0, 0, 0, 0, 0, 0, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2201 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2202 PyDoc_STR("Out of memory."), (traverseproc)BaseException_traverse, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2203 (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2204 0, 0, 0, offsetof(PyBaseExceptionObject, dict), |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2205 (initproc)BaseException_init, 0, MemoryError_new |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2206 }; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2207 PyObject *PyExc_MemoryError = (PyObject *) &_PyExc_MemoryError; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2208 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2209 |
|
42665
85c22b4d4455
Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118.
Travis E. Oliphant <oliphant@enthought.com>
parents:
42334
diff
changeset
|
2210 /* |
|
85c22b4d4455
Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118.
Travis E. Oliphant <oliphant@enthought.com>
parents:
42334
diff
changeset
|
2211 * BufferError extends Exception |
|
85c22b4d4455
Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118.
Travis E. Oliphant <oliphant@enthought.com>
parents:
42334
diff
changeset
|
2212 */ |
|
85c22b4d4455
Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118.
Travis E. Oliphant <oliphant@enthought.com>
parents:
42334
diff
changeset
|
2213 SimpleExtendsException(PyExc_Exception, BufferError, "Buffer error."); |
|
85c22b4d4455
Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118.
Travis E. Oliphant <oliphant@enthought.com>
parents:
42334
diff
changeset
|
2214 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2215 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2216 /* Warning category docstrings */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2217 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2218 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2219 * Warning extends Exception |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2220 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2221 SimpleExtendsException(PyExc_Exception, Warning, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2222 "Base class for warning categories."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2223 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2224 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2225 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2226 * UserWarning extends Warning |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2227 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2228 SimpleExtendsException(PyExc_Warning, UserWarning, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2229 "Base class for warnings generated by user code."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2230 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2231 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2232 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2233 * DeprecationWarning extends Warning |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2234 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2235 SimpleExtendsException(PyExc_Warning, DeprecationWarning, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2236 "Base class for warnings about deprecated features."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2237 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2238 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2239 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2240 * PendingDeprecationWarning extends Warning |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2241 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2242 SimpleExtendsException(PyExc_Warning, PendingDeprecationWarning, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2243 "Base class for warnings about features which will be deprecated\n" |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2244 "in the future."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2245 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2246 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2247 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2248 * SyntaxWarning extends Warning |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2249 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2250 SimpleExtendsException(PyExc_Warning, SyntaxWarning, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2251 "Base class for warnings about dubious syntax."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2252 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2253 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2254 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2255 * RuntimeWarning extends Warning |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2256 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2257 SimpleExtendsException(PyExc_Warning, RuntimeWarning, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2258 "Base class for warnings about dubious runtime behavior."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2259 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2260 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2261 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2262 * FutureWarning extends Warning |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2263 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2264 SimpleExtendsException(PyExc_Warning, FutureWarning, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2265 "Base class for warnings about constructs that will change semantically\n" |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2266 "in the future."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2267 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2268 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2269 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2270 * ImportWarning extends Warning |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2271 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2272 SimpleExtendsException(PyExc_Warning, ImportWarning, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2273 "Base class for warnings about probable mistakes in module imports"); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2274 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2275 |
|
39610
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2276 /* |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2277 * UnicodeWarning extends Warning |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2278 */ |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2279 SimpleExtendsException(PyExc_Warning, UnicodeWarning, |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2280 "Base class for warnings about Unicode related problems, mostly\n" |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2281 "related to conversion problems."); |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2282 |
|
65624
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2283 |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2284 /* |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2285 * BytesWarning extends Warning |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2286 */ |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2287 SimpleExtendsException(PyExc_Warning, BytesWarning, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2288 "Base class for warnings about bytes and buffer related problems, mostly\n" |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2289 "related to conversion from str or comparing to str."); |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2290 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2291 |
|
65624
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2292 /* |
|
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2293 * ResourceWarning extends Warning |
|
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2294 */ |
|
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2295 SimpleExtendsException(PyExc_Warning, ResourceWarning, |
|
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2296 "Base class for warnings about resource usage."); |
|
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2297 |
|
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2298 |
|
39610
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2299 |
|
43292
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2300 /* Pre-computed RuntimeError instance for when recursion depth is reached. |
|
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2301 Meant to be used when normalizing the exception for exceeding the recursion |
|
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2302 depth will cause its own infinite recursion. |
|
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2303 */ |
|
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2304 PyObject *PyExc_RecursionErrorInst = NULL; |
|
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2305 |
|
74506
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2306 #define PRE_INIT(TYPE) \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2307 if (!(_PyExc_ ## TYPE.tp_flags & Py_TPFLAGS_READY)) { \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2308 if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2309 Py_FatalError("exceptions bootstrapping error."); \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2310 Py_INCREF(PyExc_ ## TYPE); \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2311 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2312 |
|
74506
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2313 #define POST_INIT(TYPE) \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2314 if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2315 Py_FatalError("Module dictionary insertion problem."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2316 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2317 #define INIT_ALIAS(NAME, TYPE) Py_INCREF(PyExc_ ## TYPE); \ |
|
74508
29a28018e567
Fix some of the remaining test_capi refleaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74507
diff
changeset
|
2318 Py_XDECREF(PyExc_ ## NAME); \ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2319 PyExc_ ## NAME = PyExc_ ## TYPE; \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2320 if (PyDict_SetItemString(bdict, # NAME, PyExc_ ## NAME)) \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2321 Py_FatalError("Module dictionary insertion problem."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2322 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2323 #define ADD_ERRNO(TYPE, CODE) { \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2324 PyObject *_code = PyLong_FromLong(CODE); \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2325 assert(_PyObject_RealIsSubclass(PyExc_ ## TYPE, PyExc_OSError)); \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2326 if (!_code || PyDict_SetItem(errnomap, _code, PyExc_ ## TYPE)) \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2327 Py_FatalError("errmap insertion problem."); \ |
|
74508
29a28018e567
Fix some of the remaining test_capi refleaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74507
diff
changeset
|
2328 Py_DECREF(_code); \ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2329 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2330 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2331 #ifdef MS_WINDOWS |
|
83043
58fcd81acfb1
Issue #17591: Use lowercase filenames when including Windows header files.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82414
diff
changeset
|
2332 #include <winsock2.h> |
|
76898
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2333 /* The following constants were added to errno.h in VS2010 but have |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2334 preferred WSA equivalents. */ |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2335 #undef EADDRINUSE |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2336 #undef EADDRNOTAVAIL |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2337 #undef EAFNOSUPPORT |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2338 #undef EALREADY |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2339 #undef ECONNABORTED |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2340 #undef ECONNREFUSED |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2341 #undef ECONNRESET |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2342 #undef EDESTADDRREQ |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2343 #undef EHOSTUNREACH |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2344 #undef EINPROGRESS |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2345 #undef EISCONN |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2346 #undef ELOOP |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2347 #undef EMSGSIZE |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2348 #undef ENETDOWN |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2349 #undef ENETRESET |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2350 #undef ENETUNREACH |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2351 #undef ENOBUFS |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2352 #undef ENOPROTOOPT |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2353 #undef ENOTCONN |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2354 #undef ENOTSOCK |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2355 #undef EOPNOTSUPP |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2356 #undef EPROTONOSUPPORT |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2357 #undef EPROTOTYPE |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2358 #undef ETIMEDOUT |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2359 #undef EWOULDBLOCK |
|
38d7d944370e
Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents:
76303
diff
changeset
|
2360 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2361 #if defined(WSAEALREADY) && !defined(EALREADY) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2362 #define EALREADY WSAEALREADY |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2363 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2364 #if defined(WSAECONNABORTED) && !defined(ECONNABORTED) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2365 #define ECONNABORTED WSAECONNABORTED |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2366 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2367 #if defined(WSAECONNREFUSED) && !defined(ECONNREFUSED) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2368 #define ECONNREFUSED WSAECONNREFUSED |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2369 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2370 #if defined(WSAECONNRESET) && !defined(ECONNRESET) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2371 #define ECONNRESET WSAECONNRESET |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2372 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2373 #if defined(WSAEINPROGRESS) && !defined(EINPROGRESS) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2374 #define EINPROGRESS WSAEINPROGRESS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2375 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2376 #if defined(WSAESHUTDOWN) && !defined(ESHUTDOWN) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2377 #define ESHUTDOWN WSAESHUTDOWN |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2378 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2379 #if defined(WSAETIMEDOUT) && !defined(ETIMEDOUT) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2380 #define ETIMEDOUT WSAETIMEDOUT |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2381 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2382 #if defined(WSAEWOULDBLOCK) && !defined(EWOULDBLOCK) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2383 #define EWOULDBLOCK WSAEWOULDBLOCK |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2384 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2385 #endif /* MS_WINDOWS */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
2386 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47301
diff
changeset
|
2387 void |
|
76303
2dd046be2c88
Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents:
76272
diff
changeset
|
2388 _PyExc_Init(PyObject *bltinmod) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2389 { |
|
76303
2dd046be2c88
Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents:
76272
diff
changeset
|
2390 PyObject *bdict; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2391 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2392 PRE_INIT(BaseException) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2393 PRE_INIT(Exception) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2394 PRE_INIT(TypeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2395 PRE_INIT(StopIteration) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2396 PRE_INIT(GeneratorExit) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2397 PRE_INIT(SystemExit) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2398 PRE_INIT(KeyboardInterrupt) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2399 PRE_INIT(ImportError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2400 PRE_INIT(OSError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2401 PRE_INIT(EOFError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2402 PRE_INIT(RuntimeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2403 PRE_INIT(NotImplementedError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2404 PRE_INIT(NameError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2405 PRE_INIT(UnboundLocalError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2406 PRE_INIT(AttributeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2407 PRE_INIT(SyntaxError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2408 PRE_INIT(IndentationError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2409 PRE_INIT(TabError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2410 PRE_INIT(LookupError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2411 PRE_INIT(IndexError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2412 PRE_INIT(KeyError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2413 PRE_INIT(ValueError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2414 PRE_INIT(UnicodeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2415 PRE_INIT(UnicodeEncodeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2416 PRE_INIT(UnicodeDecodeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2417 PRE_INIT(UnicodeTranslateError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2418 PRE_INIT(AssertionError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2419 PRE_INIT(ArithmeticError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2420 PRE_INIT(FloatingPointError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2421 PRE_INIT(OverflowError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2422 PRE_INIT(ZeroDivisionError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2423 PRE_INIT(SystemError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2424 PRE_INIT(ReferenceError) |
|
42669
2c51be9904de
Code review of the new buffer protocol. Mostly add questions that should
Neal Norwitz <nnorwitz@gmail.com>
parents:
42665
diff
changeset
|
2425 PRE_INIT(BufferError) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2426 PRE_INIT(MemoryError) |
|
48437
fa34088380f9
#3295 actually define PyExc_BufferError
Benjamin Peterson <benjamin@python.org>
parents:
47580
diff
changeset
|
2427 PRE_INIT(BufferError) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2428 PRE_INIT(Warning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2429 PRE_INIT(UserWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2430 PRE_INIT(DeprecationWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2431 PRE_INIT(PendingDeprecationWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2432 PRE_INIT(SyntaxWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2433 PRE_INIT(RuntimeWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2434 PRE_INIT(FutureWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2435 PRE_INIT(ImportWarning) |
|
39610
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2436 PRE_INIT(UnicodeWarning) |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2437 PRE_INIT(BytesWarning) |
|
65624
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2438 PRE_INIT(ResourceWarning) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2439 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2440 /* OSError subclasses */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2441 PRE_INIT(ConnectionError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2442 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2443 PRE_INIT(BlockingIOError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2444 PRE_INIT(BrokenPipeError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2445 PRE_INIT(ChildProcessError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2446 PRE_INIT(ConnectionAbortedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2447 PRE_INIT(ConnectionRefusedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2448 PRE_INIT(ConnectionResetError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2449 PRE_INIT(FileExistsError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2450 PRE_INIT(FileNotFoundError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2451 PRE_INIT(IsADirectoryError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2452 PRE_INIT(NotADirectoryError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2453 PRE_INIT(InterruptedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2454 PRE_INIT(PermissionError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2455 PRE_INIT(ProcessLookupError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2456 PRE_INIT(TimeoutError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2457 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2458 bdict = PyModule_GetDict(bltinmod); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2459 if (bdict == NULL) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2460 Py_FatalError("exceptions bootstrapping error."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2461 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2462 POST_INIT(BaseException) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2463 POST_INIT(Exception) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2464 POST_INIT(TypeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2465 POST_INIT(StopIteration) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2466 POST_INIT(GeneratorExit) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2467 POST_INIT(SystemExit) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2468 POST_INIT(KeyboardInterrupt) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2469 POST_INIT(ImportError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2470 POST_INIT(OSError) |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2471 INIT_ALIAS(EnvironmentError, OSError) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2472 INIT_ALIAS(IOError, OSError) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2473 #ifdef MS_WINDOWS |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2474 INIT_ALIAS(WindowsError, OSError) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2475 #endif |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2476 #ifdef __VMS |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2477 INIT_ALIAS(VMSError, OSError) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2478 #endif |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2479 POST_INIT(EOFError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2480 POST_INIT(RuntimeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2481 POST_INIT(NotImplementedError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2482 POST_INIT(NameError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2483 POST_INIT(UnboundLocalError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2484 POST_INIT(AttributeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2485 POST_INIT(SyntaxError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2486 POST_INIT(IndentationError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2487 POST_INIT(TabError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2488 POST_INIT(LookupError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2489 POST_INIT(IndexError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2490 POST_INIT(KeyError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2491 POST_INIT(ValueError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2492 POST_INIT(UnicodeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2493 POST_INIT(UnicodeEncodeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2494 POST_INIT(UnicodeDecodeError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2495 POST_INIT(UnicodeTranslateError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2496 POST_INIT(AssertionError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2497 POST_INIT(ArithmeticError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2498 POST_INIT(FloatingPointError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2499 POST_INIT(OverflowError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2500 POST_INIT(ZeroDivisionError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2501 POST_INIT(SystemError) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2502 POST_INIT(ReferenceError) |
|
42669
2c51be9904de
Code review of the new buffer protocol. Mostly add questions that should
Neal Norwitz <nnorwitz@gmail.com>
parents:
42665
diff
changeset
|
2503 POST_INIT(BufferError) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2504 POST_INIT(MemoryError) |
|
48437
fa34088380f9
#3295 actually define PyExc_BufferError
Benjamin Peterson <benjamin@python.org>
parents:
47580
diff
changeset
|
2505 POST_INIT(BufferError) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2506 POST_INIT(Warning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2507 POST_INIT(UserWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2508 POST_INIT(DeprecationWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2509 POST_INIT(PendingDeprecationWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2510 POST_INIT(SyntaxWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2511 POST_INIT(RuntimeWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2512 POST_INIT(FutureWarning) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2513 POST_INIT(ImportWarning) |
|
39610
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2514 POST_INIT(UnicodeWarning) |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2515 POST_INIT(BytesWarning) |
|
65624
39b9e9de372b
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents:
62443
diff
changeset
|
2516 POST_INIT(ResourceWarning) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2517 |
|
74509
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2518 if (!errnomap) { |
|
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2519 errnomap = PyDict_New(); |
|
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2520 if (!errnomap) |
|
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2521 Py_FatalError("Cannot allocate map from errnos to OSError subclasses"); |
|
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2522 } |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2523 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2524 /* OSError subclasses */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2525 POST_INIT(ConnectionError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2526 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2527 POST_INIT(BlockingIOError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2528 ADD_ERRNO(BlockingIOError, EAGAIN); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2529 ADD_ERRNO(BlockingIOError, EALREADY); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2530 ADD_ERRNO(BlockingIOError, EINPROGRESS); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2531 ADD_ERRNO(BlockingIOError, EWOULDBLOCK); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2532 POST_INIT(BrokenPipeError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2533 ADD_ERRNO(BrokenPipeError, EPIPE); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2534 ADD_ERRNO(BrokenPipeError, ESHUTDOWN); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2535 POST_INIT(ChildProcessError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2536 ADD_ERRNO(ChildProcessError, ECHILD); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2537 POST_INIT(ConnectionAbortedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2538 ADD_ERRNO(ConnectionAbortedError, ECONNABORTED); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2539 POST_INIT(ConnectionRefusedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2540 ADD_ERRNO(ConnectionRefusedError, ECONNREFUSED); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2541 POST_INIT(ConnectionResetError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2542 ADD_ERRNO(ConnectionResetError, ECONNRESET); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2543 POST_INIT(FileExistsError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2544 ADD_ERRNO(FileExistsError, EEXIST); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2545 POST_INIT(FileNotFoundError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2546 ADD_ERRNO(FileNotFoundError, ENOENT); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2547 POST_INIT(IsADirectoryError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2548 ADD_ERRNO(IsADirectoryError, EISDIR); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2549 POST_INIT(NotADirectoryError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2550 ADD_ERRNO(NotADirectoryError, ENOTDIR); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2551 POST_INIT(InterruptedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2552 ADD_ERRNO(InterruptedError, EINTR); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2553 POST_INIT(PermissionError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2554 ADD_ERRNO(PermissionError, EACCES); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2555 ADD_ERRNO(PermissionError, EPERM); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2556 POST_INIT(ProcessLookupError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2557 ADD_ERRNO(ProcessLookupError, ESRCH); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2558 POST_INIT(TimeoutError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2559 ADD_ERRNO(TimeoutError, ETIMEDOUT); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2560 |
|
65690
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2561 preallocate_memerrors(); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2562 |
|
74498
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2563 if (!PyExc_RecursionErrorInst) { |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2564 PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2565 if (!PyExc_RecursionErrorInst) |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2566 Py_FatalError("Cannot pre-allocate RuntimeError instance for " |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2567 "recursion errors"); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2568 else { |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2569 PyBaseExceptionObject *err_inst = |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2570 (PyBaseExceptionObject *)PyExc_RecursionErrorInst; |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2571 PyObject *args_tuple; |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2572 PyObject *exc_message; |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2573 exc_message = PyUnicode_FromString("maximum recursion depth exceeded"); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2574 if (!exc_message) |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2575 Py_FatalError("cannot allocate argument for RuntimeError " |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2576 "pre-allocation"); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2577 args_tuple = PyTuple_Pack(1, exc_message); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2578 if (!args_tuple) |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2579 Py_FatalError("cannot allocate tuple for RuntimeError " |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2580 "pre-allocation"); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2581 Py_DECREF(exc_message); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2582 if (BaseException_init(err_inst, args_tuple, NULL)) |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2583 Py_FatalError("init of pre-allocated RuntimeError failed"); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2584 Py_DECREF(args_tuple); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2585 } |
|
43292
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2586 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2587 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2588 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2589 void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2590 _PyExc_Fini(void) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2591 { |
|
65690
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2592 Py_CLEAR(PyExc_RecursionErrorInst); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2593 free_preallocated_memerrors(); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2594 Py_CLEAR(errnomap); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2595 } |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2596 |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2597 /* Helper to do the equivalent of "raise X from Y" in C, but always using |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2598 * the current exception rather than passing one in. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2599 * |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2600 * We currently limit this to *only* exceptions that use the BaseException |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2601 * tp_init and tp_new methods, since we can be reasonably sure we can wrap |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2602 * those correctly without losing data and without losing backwards |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2603 * compatibility. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2604 * |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2605 * We also aim to rule out *all* exceptions that might be storing additional |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2606 * state, whether by having a size difference relative to BaseException, |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2607 * additional arguments passed in during construction or by having a |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2608 * non-empty instance dict. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2609 * |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2610 * We need to be very careful with what we wrap, since changing types to |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2611 * a broader exception type would be backwards incompatible for |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2612 * existing codecs, and with different init or new method implementations |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2613 * may either not support instantiation with PyErr_Format or lose |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2614 * information when instantiated that way. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2615 * |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2616 * XXX (ncoghlan): This could be made more comprehensive by exploiting the |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2617 * fact that exceptions are expected to support pickling. If more builtin |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2618 * exceptions (e.g. AttributeError) start to be converted to rich |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2619 * exceptions with additional attributes, that's probably a better approach |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2620 * to pursue over adding special cases for particular stateful subclasses. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2621 * |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2622 * Returns a borrowed reference to the new exception (if any), NULL if the |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2623 * existing exception was left in place. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2624 */ |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2625 PyObject * |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2626 _PyErr_TrySetFromCause(const char *format, ...) |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2627 { |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2628 PyObject* msg_prefix; |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2629 PyObject *exc, *val, *tb; |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2630 PyTypeObject *caught_type; |
|
87093
26121ae22016
Issue #17828: _PyObject_GetDictPtr() may return NULL instead of a PyObject**
Christian Heimes <christian@cheimes.de>
parents:
87089
diff
changeset
|
2631 PyObject **dictptr; |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2632 PyObject *instance_args; |
|
87267
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2633 Py_ssize_t num_args, caught_type_size, base_exc_size; |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2634 PyObject *new_exc, *new_val, *new_tb; |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2635 va_list vargs; |
|
87267
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2636 int same_basic_size; |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2637 |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2638 PyErr_Fetch(&exc, &val, &tb); |
| 87096 | 2639 caught_type = (PyTypeObject *)exc; |
|
87267
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2640 /* Ensure type info indicates no extra state is stored at the C level |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2641 * and that the type can be reinstantiated using PyErr_Format |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2642 */ |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2643 caught_type_size = caught_type->tp_basicsize; |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2644 base_exc_size = _PyExc_BaseException.tp_basicsize; |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2645 same_basic_size = ( |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2646 caught_type_size == base_exc_size || |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2647 (PyType_SUPPORTS_WEAKREFS(caught_type) && |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2648 (caught_type_size == base_exc_size + sizeof(PyObject *)) |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2649 ) |
|
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2650 ); |
| 87096 | 2651 if (caught_type->tp_init != (initproc)BaseException_init || |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2652 caught_type->tp_new != BaseException_new || |
|
87267
04e1f701aeaa
Also chain codec exceptions that allow weakrefs
Nick Coghlan <ncoghlan@gmail.com>
parents:
87110
diff
changeset
|
2653 !same_basic_size || |
| 87096 | 2654 caught_type->tp_itemsize != _PyExc_BaseException.tp_itemsize) { |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2655 /* We can't be sure we can wrap this safely, since it may contain |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2656 * more state than just the exception type. Accordingly, we just |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2657 * leave it alone. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2658 */ |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2659 PyErr_Restore(exc, val, tb); |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2660 return NULL; |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2661 } |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2662 |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2663 /* Check the args are empty or contain a single string */ |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2664 PyErr_NormalizeException(&exc, &val, &tb); |
| 87096 | 2665 instance_args = ((PyBaseExceptionObject *)val)->args; |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2666 num_args = PyTuple_GET_SIZE(instance_args); |
| 87096 | 2667 if (num_args > 1 || |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2668 (num_args == 1 && |
| 87096 | 2669 !PyUnicode_CheckExact(PyTuple_GET_ITEM(instance_args, 0)))) { |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2670 /* More than 1 arg, or the one arg we do have isn't a string |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2671 */ |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2672 PyErr_Restore(exc, val, tb); |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2673 return NULL; |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2674 } |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2675 |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2676 /* Ensure the instance dict is also empty */ |
|
87093
26121ae22016
Issue #17828: _PyObject_GetDictPtr() may return NULL instead of a PyObject**
Christian Heimes <christian@cheimes.de>
parents:
87089
diff
changeset
|
2677 dictptr = _PyObject_GetDictPtr(val); |
| 87096 | 2678 if (dictptr != NULL && *dictptr != NULL && |
| 2679 PyObject_Length(*dictptr) > 0) { | |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2680 /* While we could potentially copy a non-empty instance dictionary |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2681 * to the replacement exception, for now we take the more |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2682 * conservative path of leaving exceptions with attributes set |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2683 * alone. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2684 */ |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2685 PyErr_Restore(exc, val, tb); |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2686 return NULL; |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2687 } |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2688 |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2689 /* For exceptions that we can wrap safely, we chain the original |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2690 * exception to a new one of the exact same type with an |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2691 * error message that mentions the additional details and the |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2692 * original exception. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2693 * |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2694 * It would be nice to wrap OSError and various other exception |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2695 * types as well, but that's quite a bit trickier due to the extra |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2696 * state potentially stored on OSError instances. |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2697 */ |
|
87089
99ba1772c469
Issue #17828: va_start() must be accompanied by va_end()
Christian Heimes <christian@cheimes.de>
parents:
87084
diff
changeset
|
2698 |
| 87097 | 2699 Py_XDECREF(tb); |
| 2700 | |
|
87089
99ba1772c469
Issue #17828: va_start() must be accompanied by va_end()
Christian Heimes <christian@cheimes.de>
parents:
87084
diff
changeset
|
2701 #ifdef HAVE_STDARG_PROTOTYPES |
|
99ba1772c469
Issue #17828: va_start() must be accompanied by va_end()
Christian Heimes <christian@cheimes.de>
parents:
87084
diff
changeset
|
2702 va_start(vargs, format); |
|
99ba1772c469
Issue #17828: va_start() must be accompanied by va_end()
Christian Heimes <christian@cheimes.de>
parents:
87084
diff
changeset
|
2703 #else |
|
99ba1772c469
Issue #17828: va_start() must be accompanied by va_end()
Christian Heimes <christian@cheimes.de>
parents:
87084
diff
changeset
|
2704 va_start(vargs); |
|
99ba1772c469
Issue #17828: va_start() must be accompanied by va_end()
Christian Heimes <christian@cheimes.de>
parents:
87084
diff
changeset
|
2705 #endif |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2706 msg_prefix = PyUnicode_FromFormatV(format, vargs); |
|
87089
99ba1772c469
Issue #17828: va_start() must be accompanied by va_end()
Christian Heimes <christian@cheimes.de>
parents:
87084
diff
changeset
|
2707 va_end(vargs); |
| 87097 | 2708 if (msg_prefix == NULL) { |
|
87110
ace11097a22e
Don't decref exc too soon
Nick Coghlan <ncoghlan@gmail.com>
parents:
87106
diff
changeset
|
2709 Py_DECREF(exc); |
| 87097 | 2710 Py_DECREF(val); |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2711 return NULL; |
| 87097 | 2712 } |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2713 |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2714 PyErr_Format(exc, "%U (%s: %S)", |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2715 msg_prefix, Py_TYPE(val)->tp_name, val); |
|
87110
ace11097a22e
Don't decref exc too soon
Nick Coghlan <ncoghlan@gmail.com>
parents:
87106
diff
changeset
|
2716 Py_DECREF(exc); |
| 87097 | 2717 Py_DECREF(msg_prefix); |
|
87084
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2718 PyErr_Fetch(&new_exc, &new_val, &new_tb); |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2719 PyErr_NormalizeException(&new_exc, &new_val, &new_tb); |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2720 PyException_SetCause(new_val, val); |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2721 PyErr_Restore(new_exc, new_val, new_tb); |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2722 return new_val; |
|
854a2cea31b9
Close #17828: better handling of codec errors
Nick Coghlan <ncoghlan@gmail.com>
parents:
86484
diff
changeset
|
2723 } |
