Mercurial > cpython-lru_cache-weakref
annotate Objects/exceptions.c @ 76370:00a07720a570
Issue #14599: Fix an import caching race condition.
| author | Brett Cannon <brett@python.org> |
|---|---|
| date | Mon, 16 Apr 2012 20:50:33 -0400 |
| parents | 2dd046be2c88 |
| children | 38d7d944370e |
| 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; |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
45 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 return NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
50 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
51 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
52 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
|
53 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
54 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
55 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
56 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
|
57 { |
|
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
|
58 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
|
59 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
|
60 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
61 Py_XDECREF(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
|
62 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
|
63 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
|
64 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
65 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
66 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
67 |
|
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 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
|
69 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
|
70 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
71 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
|
72 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
|
73 Py_CLEAR(self->traceback); |
|
43188
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
74 Py_CLEAR(self->cause); |
|
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
75 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
|
76 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
77 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
78 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
79 static void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
80 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
|
81 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
82 _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
|
83 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
|
84 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
|
85 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
86 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
87 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
|
88 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
|
89 { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
90 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
|
91 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
|
92 Py_VISIT(self->traceback); |
|
43188
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
93 Py_VISIT(self->cause); |
|
386c22d93ab6
Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents:
43102
diff
changeset
|
94 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
|
95 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
96 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
97 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
98 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
99 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
|
100 { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
101 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
|
102 case 0: |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
103 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
|
104 case 1: |
|
43866
8ed0280c2ab6
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
Thomas Heller <theller@ctypes.org>
parents:
43777
diff
changeset
|
105 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
|
106 default: |
|
43866
8ed0280c2ab6
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
Thomas Heller <theller@ctypes.org>
parents:
43777
diff
changeset
|
107 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
|
108 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
109 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
110 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
111 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
112 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
|
113 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
114 char *name; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
115 char *dot; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
116 |
|
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
|
117 name = (char *)Py_TYPE(self)->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
|
118 dot = strrchr(name, '.'); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
119 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
|
120 |
|
41782
bee8d01ef42c
Add a format specifier %R to PyUnicode_FromFormat(), which embeds
Walter Dörwald <walter@livinglogic.de>
parents:
41769
diff
changeset
|
121 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
|
122 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
123 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
124 /* Pickling support */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
125 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
126 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
|
127 { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 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
|
132 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
133 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
134 /* |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
135 * 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
|
136 * 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
|
137 * 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
|
138 */ |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
139 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
|
140 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
|
141 { |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
142 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
|
143 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
|
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 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
|
146 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
|
147 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
|
148 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
|
149 } |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
150 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
|
151 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
|
152 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
|
153 } |
|
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 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
|
156 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
157 |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
158 static PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
159 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
|
160 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
|
161 return NULL; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
162 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
163 Py_INCREF(self); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
164 return self; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
165 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
166 |
|
46682
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
167 PyDoc_STRVAR(with_traceback_doc, |
|
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
168 "Exception.with_traceback(tb) --\n\ |
|
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
169 set self.__traceback__ to tb and return self."); |
|
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
170 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
171 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
172 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
|
173 {"__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
|
174 {"__setstate__", (PyCFunction)BaseException_setstate, METH_O }, |
|
46682
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
175 {"with_traceback", (PyCFunction)BaseException_with_traceback, METH_O, |
|
91d5f0841700
Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents:
44351
diff
changeset
|
176 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
|
177 {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
|
178 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
179 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
180 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
181 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
|
182 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
183 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
|
184 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
|
185 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
|
186 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
187 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
|
188 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
|
189 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
190 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
191 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
192 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
|
193 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
194 PyObject *seq; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
195 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
|
196 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
|
197 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
198 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
199 seq = PySequence_Tuple(val); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
200 if (!seq) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
205 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
206 |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
207 static PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
208 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
|
209 { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
210 if (self->traceback == NULL) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
211 Py_INCREF(Py_None); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
212 return Py_None; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
213 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
214 Py_INCREF(self->traceback); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
215 return self->traceback; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
216 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
217 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
218 static int |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
219 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
|
220 { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
221 if (tb == NULL) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
222 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
|
223 return -1; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
224 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
225 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
|
226 PyErr_SetString(PyExc_TypeError, |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
227 "__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
|
228 return -1; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
229 } |
|
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 Py_XINCREF(tb); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
232 Py_XDECREF(self->traceback); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
233 self->traceback = tb; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
234 return 0; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
235 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
236 |
|
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
|
237 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
|
238 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
|
239 PyObject *res = PyException_GetContext(self); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
240 if (res) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
241 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
|
242 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
|
243 } |
|
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
|
244 |
|
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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 } 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
|
251 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
|
252 } 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
|
253 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
|
254 "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
|
255 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
|
256 } 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
|
257 /* 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
|
258 Py_INCREF(arg); |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59128
diff
changeset
|
259 } |
|
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
|
260 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
|
261 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
|
262 } |
|
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 |
|
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 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
|
265 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
|
266 PyObject *res = PyException_GetCause(self); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
267 if (res) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
268 return res; /* new reference already returned above */ |
|
75292
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
269 Py_INCREF(Py_Ellipsis); |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
270 return Py_Ellipsis; |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
271 } |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
272 |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
273 int |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
274 _PyException_SetCauseChecked(PyObject *self, PyObject *arg) { |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
275 if (arg == Py_Ellipsis) { |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
276 arg = NULL; |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
277 } else if (arg != Py_None && !PyExceptionInstance_Check(arg)) { |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
278 PyErr_SetString(PyExc_TypeError, "exception cause must be None, " |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
279 "Ellipsis or derive from BaseException"); |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
280 return -1; |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
281 } else { |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
282 /* PyException_SetCause steals a reference */ |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
283 Py_INCREF(arg); |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
284 } |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
285 PyException_SetCause(self, arg); |
|
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
286 return 0; |
|
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
|
287 } |
|
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 |
|
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 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
|
290 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
|
291 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
|
292 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
|
293 return -1; |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59128
diff
changeset
|
294 } |
|
75292
b299c4f31ff2
Close issue #6210: Implement PEP 409
Nick Coghlan <ncoghlan@gmail.com>
parents:
75051
diff
changeset
|
295 return _PyException_SetCauseChecked(self, arg); |
|
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
|
296 } |
|
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 |
|
41716
00c02c4488ce
Merged revisions 55325-55327 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41611
diff
changeset
|
298 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
299 static PyGetSetDef BaseException_getset[] = { |
|
75051
f029312764b4
use new generic __dict__ descriptor implementations
Benjamin Peterson <benjamin@python.org>
parents:
74865
diff
changeset
|
300 {"__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
|
301 {"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
|
302 {"__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
|
303 {"__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
|
304 (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
|
305 {"__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
|
306 (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
|
307 {NULL}, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
308 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
309 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
310 |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
311 PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
312 PyException_GetTraceback(PyObject *self) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
313 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
|
314 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
|
315 return base_self->traceback; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
316 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
317 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
318 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
319 int |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
320 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
|
321 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
|
322 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
323 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
324 PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
325 PyException_GetCause(PyObject *self) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
326 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
|
327 Py_XINCREF(cause); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
328 return cause; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
329 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
330 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
331 /* 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
|
332 void |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
333 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
|
334 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
|
335 ((PyBaseExceptionObject *)self)->cause = cause; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
336 Py_XDECREF(old_cause); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
337 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
338 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
339 PyObject * |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
340 PyException_GetContext(PyObject *self) { |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
341 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
|
342 Py_XINCREF(context); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
343 return context; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
344 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
345 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
346 /* 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
|
347 void |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
348 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
|
349 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
|
350 ((PyBaseExceptionObject *)self)->context = context; |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
351 Py_XDECREF(old_context); |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
352 } |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
353 |
|
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42855
diff
changeset
|
354 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
355 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
|
356 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
|
357 "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
|
358 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
|
359 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
|
360 (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
|
361 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
|
362 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
|
363 0, /*tp_setattr*/ |
|
51271
87fbbf22adf3
Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
50886
diff
changeset
|
364 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
|
365 (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
|
366 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
|
367 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
|
368 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
|
369 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
|
370 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
|
371 (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
|
372 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
|
373 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
|
374 0, /*tp_as_buffer*/ |
|
40909
f2f0b41f270d
Merged revisions 53875-53911 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40626
diff
changeset
|
375 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
|
376 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
|
377 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
|
378 (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
|
379 (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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 BaseException_methods, /* tp_methods */ |
|
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
|
385 0, /* 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 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
|
392 (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
|
393 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
|
394 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
|
395 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
396 /* 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
|
397 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
|
398 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
|
399 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
|
400 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
401 /* 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
|
402 * 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
|
403 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
404 #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
|
405 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
|
406 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
|
407 # EXCNAME, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
408 sizeof(PyBaseExceptionObject), \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
409 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
|
410 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
|
411 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
|
412 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
|
413 (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
|
414 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
|
415 (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
|
416 }; \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
417 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
|
418 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
419 #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
|
420 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
|
421 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
|
422 # EXCNAME, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
423 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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 (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
|
429 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
|
430 (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
|
431 }; \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
432 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
|
433 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
434 #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
|
435 EXCMETHODS, EXCMEMBERS, EXCGETSET, \ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
436 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
|
437 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
|
438 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
|
439 # EXCNAME, \ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
440 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
|
441 (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
|
442 (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
|
443 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
|
444 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
|
445 (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
|
446 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
|
447 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
|
448 (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
|
449 }; \ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
450 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
|
451 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
452 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
453 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
454 * 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
|
455 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
456 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
|
457 "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
|
458 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
459 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
460 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
461 * 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
|
462 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
463 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
|
464 "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
|
465 |
|
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 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
468 * 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
|
469 */ |
|
74356
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
470 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
471 static PyMemberDef StopIteration_members[] = { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
472 {"value", T_OBJECT, offsetof(PyStopIterationObject, value), 0, |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
473 PyDoc_STR("generator return value")}, |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
474 {NULL} /* Sentinel */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
475 }; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
476 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
477 static int |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
478 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
|
479 { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
480 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
|
481 PyObject *value; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
482 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
483 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
|
484 return -1; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
485 Py_CLEAR(self->value); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
486 if (size > 0) |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
487 value = PyTuple_GET_ITEM(args, 0); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
488 else |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
489 value = Py_None; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
490 Py_INCREF(value); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
491 self->value = value; |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
492 return 0; |
|
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 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
495 static int |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
496 StopIteration_clear(PyStopIterationObject *self) |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
497 { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
498 Py_CLEAR(self->value); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
499 return BaseException_clear((PyBaseExceptionObject *)self); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
500 } |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
501 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
502 static void |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
503 StopIteration_dealloc(PyStopIterationObject *self) |
|
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 _PyObject_GC_UNTRACK(self); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
506 StopIteration_clear(self); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
507 Py_TYPE(self)->tp_free((PyObject *)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 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
510 static int |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
511 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
|
512 { |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
513 Py_VISIT(self->value); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
514 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); |
|
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 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
517 PyObject * |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
518 PyStopIteration_Create(PyObject *value) |
|
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 return PyObject_CallFunctionObjArgs(PyExc_StopIteration, value, NULL); |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
521 } |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
522 |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
523 ComplexExtendsException( |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
524 PyExc_Exception, /* base */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
525 StopIteration, /* name */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
526 StopIteration, /* prefix for *_init, etc */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
527 0, /* new */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
528 0, /* methods */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
529 StopIteration_members, /* members */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
530 0, /* getset */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
531 0, /* str */ |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
532 "Signal the end from iterator.__next__()." |
|
d64ac9ab4cd0
Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents:
73981
diff
changeset
|
533 ); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
534 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
535 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
536 /* |
|
44129
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44125
diff
changeset
|
537 * 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
|
538 */ |
|
44129
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44125
diff
changeset
|
539 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
|
540 "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
|
541 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
542 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
543 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
544 * 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
|
545 */ |
|
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 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
548 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
|
549 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
550 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
|
551 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
552 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
|
553 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
554 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
555 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
|
556 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
|
557 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
|
558 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
564 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
565 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
566 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
|
567 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
|
568 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
569 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
|
570 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
|
571 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
572 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
573 static void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
574 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
|
575 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
576 _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
|
577 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
|
578 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
|
579 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
580 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
581 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
|
582 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
|
583 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
584 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
|
585 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
|
586 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
587 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
588 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
|
589 {"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
|
590 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
|
591 {NULL} /* Sentinel */ |
|
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 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
594 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
|
595 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
|
596 "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
|
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 * 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
|
600 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
601 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
|
602 "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
|
603 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
604 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
605 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
606 * 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
|
607 */ |
|
76272
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
608 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
609 static int |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
610 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
|
611 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
612 PyObject *msg = NULL; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
613 PyObject *name = NULL; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
614 PyObject *path = NULL; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
615 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
616 /* 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
|
617 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
|
618 #define GET_KWD(kwd) { \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
619 kwd = PyDict_GetItemString(kwds, #kwd); \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
620 if (kwd) { \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
621 Py_CLEAR(self->kwd); \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
622 self->kwd = kwd; \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
623 Py_INCREF(self->kwd);\ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
624 if (PyDict_DelItemString(kwds, #kwd)) \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
625 return -1; \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
626 } \ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
627 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
628 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
629 if (kwds) { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
630 GET_KWD(name); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
631 GET_KWD(path); |
|
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 (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
|
635 return -1; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
636 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
|
637 return 0; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
638 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
|
639 return -1; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
640 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
641 Py_CLEAR(self->msg); /* replacing */ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
642 self->msg = msg; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
643 Py_INCREF(self->msg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
644 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
645 return 0; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
646 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
647 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
648 static int |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
649 ImportError_clear(PyImportErrorObject *self) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
650 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
651 Py_CLEAR(self->msg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
652 Py_CLEAR(self->name); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
653 Py_CLEAR(self->path); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
654 return BaseException_clear((PyBaseExceptionObject *)self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
655 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
656 |
|
76272
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
657 static void |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
658 ImportError_dealloc(PyImportErrorObject *self) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
659 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
660 _PyObject_GC_UNTRACK(self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
661 ImportError_clear(self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
662 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
|
663 } |
|
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 static int |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
666 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
|
667 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
668 Py_VISIT(self->msg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
669 Py_VISIT(self->name); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
670 Py_VISIT(self->path); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
671 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
|
672 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
673 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
674 static PyObject * |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
675 ImportError_str(PyImportErrorObject *self) |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
676 { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
677 if (self->msg) { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
678 Py_INCREF(self->msg); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
679 return self->msg; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
680 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
681 else { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
682 return BaseException_str((PyBaseExceptionObject *)self); |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
683 } |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
684 } |
|
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 static PyMemberDef ImportError_members[] = { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
687 {"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
|
688 PyDoc_STR("exception message")}, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
689 {"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
|
690 PyDoc_STR("module name")}, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
691 {"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
|
692 PyDoc_STR("module path")}, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
693 {NULL} /* Sentinel */ |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
694 }; |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
695 |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
696 static PyMethodDef ImportError_methods[] = { |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
697 {NULL} |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
698 }; |
|
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 ComplexExtendsException(PyExc_Exception, ImportError, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
701 ImportError, 0 /* new */, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
702 ImportError_methods, ImportError_members, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
703 0 /* getset */, ImportError_str, |
|
6825fd9b00ed
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents:
75292
diff
changeset
|
704 "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
|
705 "module."); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
706 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
707 /* |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
708 * 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
|
709 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
710 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
711 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
712 #include "errmap.h" |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
713 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
714 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
715 /* 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
|
716 * 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
|
717 * 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
|
718 * 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
|
719 * |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
720 * 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
|
721 * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
722 * 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
|
723 * 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
|
724 * 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
|
725 */ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
726 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
727 /* 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
|
728 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
|
729 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
|
730 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
|
731 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
|
732 #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
|
733 , 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
|
734 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
735 ) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
736 { |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
737 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
|
738 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
|
739 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
740 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
|
741 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
742 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
743 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
|
744 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
|
745 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
|
746 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
|
747 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
|
748 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
|
749 PyObject *newargs; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
750 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
|
751 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
752 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
|
753 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
|
754 return -1; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
755 /* 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
|
756 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
|
757 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
|
758 */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
759 if (winerrcode < 10000) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
760 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
|
761 else |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
762 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
|
763 *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
|
764 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
|
765 return -1; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
766 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
|
767 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
|
768 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
|
769 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
|
770 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
|
771 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
|
772 Py_INCREF(val); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
773 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
|
774 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
775 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
|
776 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
|
777 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
778 } |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
779 #else |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
780 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
|
781 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
|
782 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
|
783 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
|
784 } |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
785 #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
|
786 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
787 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
|
788 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
789 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
790 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
|
791 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
|
792 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
|
793 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
|
794 #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
|
795 , 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
|
796 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
797 ) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
798 { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
799 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
|
800 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
|
801 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
802 /* 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
|
803 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
|
804 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
|
805 PyNumber_Check(filename)) { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
806 /* 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
|
807 * characters written. |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
808 */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
809 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
|
810 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
|
811 return -1; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
812 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
813 else { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
814 Py_INCREF(filename); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
815 self->filename = filename; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
816 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
817 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
|
818 /* 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
|
819 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
|
820 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
|
821 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
|
822 return -1; |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
823 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
824 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
|
825 *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
|
826 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
827 } |
|
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_XINCREF(myerrno); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
830 self->myerrno = myerrno; |
|
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 Py_XINCREF(strerror); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
833 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
|
834 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
835 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
836 Py_XINCREF(winerror); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
837 self->winerror = winerror; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
838 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
839 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
840 /* Steals the reference to args */ |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
841 self->args = args; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
842 args = NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
843 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
844 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
|
845 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
846 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
847 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
|
848 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
|
849 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
|
850 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
|
851 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
852 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
|
853 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
|
854 { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
855 /* 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
|
856 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
|
857 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
|
858 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
|
859 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
860 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
|
861 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
|
862 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
863 (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
|
864 */ |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
865 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
|
866 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
|
867 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
|
868 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
|
869 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
870 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
871 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
872 |
|
73981
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
873 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
|
874 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
|
875 { |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
876 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
|
877 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
|
878 #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
|
879 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
|
880 #endif |
|
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 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
|
883 if (!_PyArg_NoKeywords(type->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
|
884 return NULL; |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
885 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
886 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
|
887 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
|
888 #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
|
889 , &winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
890 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
891 )) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
892 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
|
893 |
|
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 (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
|
895 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
|
896 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
|
897 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
|
898 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
|
899 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
|
900 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
|
901 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
902 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
|
903 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
|
904 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
905 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
906 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
907 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
|
908 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
|
909 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
|
910 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
911 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
|
912 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
|
913 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
|
914 |
|
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 (!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
|
916 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
|
917 #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
|
918 , winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
919 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
920 )) |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
921 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
|
922 } |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
923 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
924 return (PyObject *) self; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
925 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
926 error: |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
927 Py_XDECREF(args); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
928 Py_XDECREF(self); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
929 return NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
930 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
931 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
932 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
|
933 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
|
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 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
|
936 #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
|
937 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
|
938 #endif |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
939 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
940 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
|
941 /* 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
|
942 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
|
943 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
944 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
|
945 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
|
946 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
947 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
|
948 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
|
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 , &winerror |
|
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 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
|
954 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
955 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
|
956 #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
|
957 , winerror |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
958 #endif |
|
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 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
|
961 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
962 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
|
963 |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
964 error: |
|
d22c99e77768
Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents:
73655
diff
changeset
|
965 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
|
966 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
|
967 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
968 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
969 static int |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
970 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
|
971 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
972 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
|
973 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
|
974 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
|
975 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
976 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
|
977 #endif |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
978 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
|
979 } |
|
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 static void |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
982 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
|
983 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
984 _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
|
985 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
|
986 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
|
987 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
988 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
989 static int |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
990 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
|
991 void *arg) |
|
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 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
|
994 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
|
995 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
|
996 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
997 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
|
998 #endif |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
999 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
|
1000 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1001 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1002 static PyObject * |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1003 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
|
1004 { |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1005 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1006 /* 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
|
1007 if (self->winerror && self->filename) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1008 return PyUnicode_FromFormat("[Error %S] %S: %R", |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1009 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
|
1010 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
|
1011 self->filename); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1012 if (self->winerror && self->strerror) |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1013 return PyUnicode_FromFormat("[Error %S] %S", |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1014 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
|
1015 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
|
1016 #endif |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1017 if (self->filename) |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1018 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
|
1019 self->myerrno ? self->myerrno: Py_None, |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1020 self->strerror ? self->strerror: Py_None, |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1021 self->filename); |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1022 if (self->myerrno && self->strerror) |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1023 return PyUnicode_FromFormat("[Errno %S] %S", |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1024 self->myerrno ? self->myerrno: Py_None, |
|
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1025 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
|
1026 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
|
1027 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1028 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1029 static PyObject * |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1030 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
|
1031 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1032 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
|
1033 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
|
1034 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1035 /* 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
|
1036 * 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
|
1037 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
|
1038 args = PyTuple_New(3); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
1039 if (!args) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
1040 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
|
1041 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1042 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
|
1043 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
|
1044 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
|
1045 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1046 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
|
1047 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
|
1048 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
|
1049 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1050 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
|
1051 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
|
1052 } else |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1053 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
|
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 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
|
1056 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
|
1057 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
|
1058 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
|
1059 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
|
1060 return res; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1061 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1062 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1063 static PyObject * |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1064 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
|
1065 { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1066 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
|
1067 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
|
1068 return NULL; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1069 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1070 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
|
1071 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1072 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1073 static int |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1074 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
|
1075 { |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1076 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
|
1077 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
|
1078 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
|
1079 return -1; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1080 self->written = n; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1081 return 0; |
|
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 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1084 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
|
1085 {"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
|
1086 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
|
1087 {"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
|
1088 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
|
1089 {"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
|
1090 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
|
1091 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1092 {"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
|
1093 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
|
1094 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1095 {NULL} /* Sentinel */ |
|
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 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1098 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
|
1099 {"__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
|
1100 {NULL} |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1101 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1102 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1103 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
|
1104 {"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
|
1105 (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
|
1106 {NULL} |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1107 }; |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1108 |
|
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 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
|
1111 OSError, OSError_new, |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1112 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
|
1113 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
|
1114 "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
|
1115 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1116 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1117 /* |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1118 * 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
|
1119 */ |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1120 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
|
1121 "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
|
1122 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
|
1123 "Connection error."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1124 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
|
1125 "Child process error."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1126 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
|
1127 "Broken pipe."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1128 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
|
1129 "Connection aborted."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1130 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
|
1131 "Connection refused."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1132 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
|
1133 "Connection reset."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1134 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
|
1135 "File already exists."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1136 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
|
1137 "File not found."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1138 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
|
1139 "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
|
1140 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
|
1141 "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
|
1142 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
|
1143 "Interrupted by signal."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1144 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
|
1145 "Not enough permissions."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1146 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
|
1147 "Process not found."); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
1148 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
|
1149 "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
|
1150 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1151 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1152 * 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
|
1153 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1154 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
|
1155 "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
|
1156 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1157 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1158 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1159 * 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
|
1160 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1161 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
|
1162 "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
|
1163 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1164 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1165 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1166 * 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
|
1167 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1168 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
|
1169 "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
|
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 * 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
|
1173 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1174 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
|
1175 "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
|
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 * 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
|
1179 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1180 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
|
1181 "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
|
1182 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1183 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1184 * 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
|
1185 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1186 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
|
1187 "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
|
1188 |
|
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 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1191 * 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
|
1192 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1193 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1194 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1195 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
|
1196 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1197 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
|
1198 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
|
1199 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1200 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
|
1201 return -1; |
|
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 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
|
1204 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
|
1205 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
|
1206 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
|
1207 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1208 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
|
1209 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
|
1210 info = PySequence_Tuple(info); |
|
74752
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
1211 if (!info) |
|
e35f1c431302
put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents:
74506
diff
changeset
|
1212 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
|
1213 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1214 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
|
1215 /* 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
|
1216 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
|
1217 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
|
1218 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
|
1219 } |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1220 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1221 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
|
1222 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
|
1223 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
|
1224 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1225 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
|
1226 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
|
1227 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
|
1228 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1229 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
|
1230 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
|
1231 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
|
1232 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1233 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
|
1234 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
|
1235 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
|
1236 |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1237 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
|
1238 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1239 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1240 } |
|
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 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
|
1243 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
|
1244 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1245 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
|
1246 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
|
1247 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
|
1248 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
|
1249 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
|
1250 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
|
1251 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
|
1252 } |
|
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 static void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1255 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
|
1256 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
1257 _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
|
1258 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
|
1259 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
|
1260 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1261 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1262 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
|
1263 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
|
1264 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1265 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
|
1266 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
|
1267 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
|
1268 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
|
1269 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
|
1270 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
|
1271 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
|
1272 } |
|
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 /* 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
|
1275 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
|
1276 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
|
1277 static PyObject* |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1278 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
|
1279 { |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1280 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
|
1281 int kind; |
|
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1282 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
|
1283 |
|
72703
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1284 if (PyUnicode_READY(name)) |
|
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1285 return NULL; |
|
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1286 kind = PyUnicode_KIND(name); |
|
eb2821cc3edf
Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents:
72475
diff
changeset
|
1287 data = PyUnicode_DATA(name); |
| 72475 | 1288 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
|
1289 offset = 0; |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1290 for(i=0; i < size; i++) { |
| 72475 | 1291 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
|
1292 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
|
1293 } |
| 72475 | 1294 if (offset != 0) |
| 1295 return PyUnicode_Substring(name, offset, size); | |
| 1296 else { | |
|
61058
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1297 Py_INCREF(name); |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1298 return name; |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1299 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1300 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1301 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1302 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1303 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1304 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
|
1305 { |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1306 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
|
1307 PyObject *filename; |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1308 PyObject *result; |
|
44158
81e0c0e2a8c1
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents:
44129
diff
changeset
|
1309 /* 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
|
1310 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
|
1311 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
|
1312 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
|
1313 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1314 /* 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
|
1315 lineno here */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1316 |
|
42855
d5b52d56beba
Use unicode and remove support for some uses of str8.
Neal Norwitz <nnorwitz@gmail.com>
parents:
42669
diff
changeset
|
1317 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
|
1318 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
|
1319 if (filename == NULL) |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1320 return NULL; |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1321 } else { |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1322 filename = NULL; |
|
42305
d0719406b2c6
Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents:
42118
diff
changeset
|
1323 } |
|
44158
81e0c0e2a8c1
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents:
44129
diff
changeset
|
1324 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
|
1325 |
|
42305
d0719406b2c6
Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents:
42118
diff
changeset
|
1326 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
|
1327 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
|
1328 |
|
42305
d0719406b2c6
Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents:
42118
diff
changeset
|
1329 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
|
1330 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
|
1331 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
|
1332 filename, |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59128
diff
changeset
|
1333 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
|
1334 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
|
1335 result = PyUnicode_FromFormat("%S (%U)", |
|
41882
1056530616ac
Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents:
41782
diff
changeset
|
1336 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
|
1337 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
|
1338 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
|
1339 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
|
1340 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
|
1341 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
|
1342 Py_XDECREF(filename); |
|
04a18e59cc2c
Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
59127
diff
changeset
|
1343 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
|
1344 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1345 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1346 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
|
1347 {"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
|
1348 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
|
1349 {"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
|
1350 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
|
1351 {"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
|
1352 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
|
1353 {"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
|
1354 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
|
1355 {"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
|
1356 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
|
1357 {"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
|
1358 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
|
1359 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
|
1360 {NULL} /* Sentinel */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1361 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1362 |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1363 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
|
1364 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
|
1365 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
|
1366 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1367 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1368 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1369 * 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
|
1370 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1371 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
|
1372 "Improper indentation."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1373 |
|
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 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1376 * 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
|
1377 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1378 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
|
1379 "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
|
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 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1383 * 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
|
1384 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1385 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
|
1386 "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
|
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 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1390 * 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
|
1391 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1392 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
|
1393 "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
|
1394 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1395 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1396 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1397 * 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
|
1398 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1399 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1400 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
|
1401 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1402 /* 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
|
1403 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
|
1404 KeyError: '' |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1405 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
|
1406 KeyError |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1407 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
|
1408 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
|
1409 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
|
1410 */ |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1411 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
|
1412 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
|
1413 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1414 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
|
1415 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1416 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1417 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
|
1418 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
|
1419 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1420 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1421 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1422 * 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
|
1423 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
1424 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
|
1425 "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
|
1426 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1427 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1428 * 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
|
1429 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1430 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1431 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
|
1432 "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
|
1433 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1434 static PyObject * |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1435 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
|
1436 { |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1437 if (!attr) { |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1438 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
|
1439 return NULL; |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1440 } |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1441 |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1442 if (!PyBytes_Check(attr)) { |
|
41611
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1443 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
|
1444 return NULL; |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1445 } |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1446 Py_INCREF(attr); |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1447 return attr; |
|
c48fe4dc34a9
Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents:
41587
diff
changeset
|
1448 } |
|
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 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
|
1451 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
|
1452 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1453 if (!attr) { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1454 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
|
1455 return NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1456 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1457 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1458 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
|
1459 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
|
1460 "%.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
|
1461 return NULL; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1462 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1463 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
|
1464 return attr; |
|
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 |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1467 static int |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1468 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
|
1469 { |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1470 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
|
1471 if (!obj) |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1472 return -1; |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1473 Py_CLEAR(*attr); |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1474 *attr = obj; |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1475 return 0; |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1476 } |
|
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1477 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1478 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1479 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
|
1480 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1481 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
|
1482 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1483 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1484 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1485 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
|
1486 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1487 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
|
1488 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1489 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1490 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1491 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
|
1492 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1493 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
|
1494 } |
|
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 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1497 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
|
1498 { |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1499 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
|
1500 } |
|
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 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1503 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
|
1504 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1505 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
|
1506 } |
|
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 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1509 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
|
1510 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1511 Py_ssize_t size; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1512 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
|
1513 "object"); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1514 if (!obj) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1515 return -1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1516 *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
|
1517 size = PyUnicode_GET_LENGTH(obj); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1518 if (*start<0) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1519 *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
|
1520 if (*start>=size) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1521 *start = size-1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1522 Py_DECREF(obj); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1523 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
|
1524 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1525 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1526 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1527 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1528 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
|
1529 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1530 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
|
1531 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
|
1532 if (!obj) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1533 return -1; |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1534 size = PyBytes_GET_SIZE(obj); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1535 *start = ((PyUnicodeErrorObject *)exc)->start; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1536 if (*start<0) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1537 *start = 0; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1538 if (*start>=size) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1539 *start = size-1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1540 Py_DECREF(obj); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1541 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
|
1542 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1543 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1544 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1545 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1546 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
|
1547 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1548 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
|
1549 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1550 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1551 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1552 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1553 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
|
1554 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1555 ((PyUnicodeErrorObject *)exc)->start = start; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1556 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
|
1557 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1558 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1559 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1560 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1561 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
|
1562 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1563 ((PyUnicodeErrorObject *)exc)->start = start; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1564 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
|
1565 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1566 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1567 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1568 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1569 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
|
1570 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1571 ((PyUnicodeErrorObject *)exc)->start = start; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1572 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
|
1573 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1574 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1575 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1576 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1577 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
|
1578 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1579 Py_ssize_t size; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1580 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
|
1581 "object"); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1582 if (!obj) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1583 return -1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1584 *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
|
1585 size = PyUnicode_GET_LENGTH(obj); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1586 if (*end<1) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1587 *end = 1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1588 if (*end>size) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1589 *end = size; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1590 Py_DECREF(obj); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1591 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
|
1592 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1593 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1594 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1595 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1596 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
|
1597 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1598 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
|
1599 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
|
1600 if (!obj) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1601 return -1; |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1602 size = PyBytes_GET_SIZE(obj); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1603 *end = ((PyUnicodeErrorObject *)exc)->end; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1604 if (*end<1) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1605 *end = 1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1606 if (*end>size) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1607 *end = size; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1608 Py_DECREF(obj); |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1609 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
|
1610 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1611 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1612 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1613 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1614 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
|
1615 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1616 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
|
1617 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1618 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1619 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1620 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1621 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
|
1622 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1623 ((PyUnicodeErrorObject *)exc)->end = end; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1624 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
|
1625 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1626 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1627 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1628 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1629 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
|
1630 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1631 ((PyUnicodeErrorObject *)exc)->end = end; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1632 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
|
1633 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1634 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1635 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1636 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1637 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
|
1638 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1639 ((PyUnicodeErrorObject *)exc)->end = end; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1640 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
|
1641 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1642 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1643 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1644 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
|
1645 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1646 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
|
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 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1650 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1651 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
|
1652 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1653 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
|
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 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1657 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1658 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
|
1659 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1660 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
|
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 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1664 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1665 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
|
1666 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1667 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
|
1668 reason); |
|
38453
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 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1671 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1672 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1673 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
|
1674 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1675 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
|
1676 reason); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1677 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1678 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1679 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1680 int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1681 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
|
1682 { |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1683 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
|
1684 reason); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1685 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1686 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1687 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1688 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1689 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
|
1690 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1691 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
|
1692 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
|
1693 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
|
1694 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
|
1695 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1696 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1697 static void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1698 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
|
1699 { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39610
diff
changeset
|
1700 _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
|
1701 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
|
1702 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
|
1703 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1704 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1705 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
|
1706 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
|
1707 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1708 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
|
1709 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
|
1710 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
|
1711 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
|
1712 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1713 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1714 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
|
1715 {"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
|
1716 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
|
1717 {"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
|
1718 PyDoc_STR("exception object")}, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1719 {"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
|
1720 PyDoc_STR("exception start")}, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1721 {"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
|
1722 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
|
1723 {"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
|
1724 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
|
1725 {NULL} /* Sentinel */ |
|
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 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1728 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1729 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1730 * 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
|
1731 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1732 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1733 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1734 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
|
1735 { |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1736 PyUnicodeErrorObject *err; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1737 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1738 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
|
1739 return -1; |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1740 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1741 err = (PyUnicodeErrorObject *)self; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1742 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1743 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
|
1744 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
|
1745 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
|
1746 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1747 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
|
1748 &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
|
1749 &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
|
1750 &err->start, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1751 &err->end, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1752 &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
|
1753 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
|
1754 return -1; |
|
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 |
|
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
|
1757 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
|
1758 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
|
1759 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
|
1760 } |
|
0883d6a103a0
Port error handlers from Py_UNICODE indexing to code point indexing.
Martin v. Löwis <martin@v.loewis.de>
parents:
72879
diff
changeset
|
1761 |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1762 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
|
1763 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
|
1764 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
|
1765 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1766 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
|
1767 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1768 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1769 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1770 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
|
1771 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1772 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1773 PyObject *result = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1774 PyObject *reason_str = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1775 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
|
1776 |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1777 /* 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
|
1778 they've been modified after we were contructed. */ |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1779 reason_str = PyObject_Str(uself->reason); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1780 if (reason_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1781 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1782 encoding_str = PyObject_Str(uself->encoding); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1783 if (encoding_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1784 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1785 |
|
73644
5b426bf9260c
UnicodeEncodeError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73350
diff
changeset
|
1786 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
|
1787 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
|
1788 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
|
1789 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
|
1790 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
|
1791 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
|
1792 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
|
1793 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
|
1794 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
|
1795 result = PyUnicode_FromFormat( |
|
41940
5014f8daa57f
PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents:
41882
diff
changeset
|
1796 fmt, |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1797 encoding_str, |
|
73644
5b426bf9260c
UnicodeEncodeError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73350
diff
changeset
|
1798 (int)badchar, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1799 uself->start, |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1800 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
|
1801 } |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1802 else { |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1803 result = PyUnicode_FromFormat( |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1804 "'%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
|
1805 encoding_str, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1806 uself->start, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1807 uself->end-1, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1808 reason_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1809 } |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1810 done: |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1811 Py_XDECREF(reason_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1812 Py_XDECREF(encoding_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1813 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
|
1814 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1815 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1816 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
|
1817 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
|
1818 "UnicodeEncodeError", |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1819 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
|
1820 (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
|
1821 (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
|
1822 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
|
1823 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
|
1824 (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
|
1825 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
|
1826 (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
|
1827 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1828 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
|
1829 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1830 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1831 PyUnicodeEncodeError_Create( |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1832 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
|
1833 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
|
1834 { |
|
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
|
1835 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
|
1836 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
|
1837 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1838 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1839 |
|
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 * 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
|
1842 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1843 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1844 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1845 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
|
1846 { |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1847 PyUnicodeErrorObject *ude; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1848 const char *data; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1849 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
|
1850 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1851 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
|
1852 return -1; |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1853 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1854 ude = (PyUnicodeErrorObject *)self; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1855 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1856 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
|
1857 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
|
1858 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
|
1859 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1860 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
|
1861 &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
|
1862 &ude->object, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1863 &ude->start, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1864 &ude->end, |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1865 &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
|
1866 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
|
1867 return -1; |
|
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 |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1870 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
|
1871 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
|
1872 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
|
1873 return -1; |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1874 } |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
46682
diff
changeset
|
1875 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
|
1876 } |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1877 else { |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1878 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
|
1879 } |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1880 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1881 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
|
1882 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
|
1883 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
1884 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
|
1885 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1886 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1887 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1888 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
|
1889 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1890 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1891 PyObject *result = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1892 PyObject *reason_str = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1893 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
|
1894 |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1895 /* 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
|
1896 they've been modified after we were contructed. */ |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1897 reason_str = PyObject_Str(uself->reason); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1898 if (reason_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1899 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1900 encoding_str = PyObject_Str(uself->encoding); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1901 if (encoding_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1902 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1903 |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1904 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
|
1905 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
|
1906 result = PyUnicode_FromFormat( |
|
41940
5014f8daa57f
PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents:
41882
diff
changeset
|
1907 "'%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
|
1908 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
|
1909 byte, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1910 uself->start, |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1911 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
|
1912 } |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1913 else { |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1914 result = PyUnicode_FromFormat( |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1915 "'%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
|
1916 encoding_str, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1917 uself->start, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1918 uself->end-1, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1919 reason_str |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1920 ); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1921 } |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1922 done: |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1923 Py_XDECREF(reason_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1924 Py_XDECREF(encoding_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1925 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
|
1926 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1927 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1928 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
|
1929 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
|
1930 "UnicodeDecodeError", |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1931 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
|
1932 (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
|
1933 (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
|
1934 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
|
1935 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
|
1936 (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
|
1937 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
|
1938 (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
|
1939 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1940 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
|
1941 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1942 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1943 PyUnicodeDecodeError_Create( |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1944 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
|
1945 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
|
1946 { |
|
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
|
1947 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
|
1948 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
|
1949 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1950 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1951 |
|
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 * 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
|
1954 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1955 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1956 static int |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1957 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
|
1958 PyObject *kwds) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1959 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1960 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
|
1961 return -1; |
|
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 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
|
1964 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
|
1965 |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1966 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
|
1967 &PyUnicode_Type, &self->object, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1968 &self->start, |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1969 &self->end, |
|
41766
d6aa7edf217a
Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents:
41749
diff
changeset
|
1970 &PyUnicode_Type, &self->reason)) { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1971 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
|
1972 return -1; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1973 } |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1974 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1975 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
|
1976 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
|
1977 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1978 return 0; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1979 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1980 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1981 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1982 static PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1983 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
|
1984 { |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
1985 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self; |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1986 PyObject *result = NULL; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1987 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
|
1988 |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1989 /* 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
|
1990 modified after we were contructed. */ |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1991 reason_str = PyObject_Str(uself->reason); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1992 if (reason_str == NULL) |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1993 goto done; |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
1994 |
|
73649
244d9159aa38
UnicodeTranslateError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73644
diff
changeset
|
1995 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
|
1996 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
|
1997 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
|
1998 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
|
1999 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
|
2000 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
|
2001 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
|
2002 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
|
2003 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
|
2004 result = PyUnicode_FromFormat( |
|
41940
5014f8daa57f
PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents:
41882
diff
changeset
|
2005 fmt, |
|
73649
244d9159aa38
UnicodeTranslateError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents:
73644
diff
changeset
|
2006 (int)badchar, |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
2007 uself->start, |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2008 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
|
2009 ); |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2010 } else { |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2011 result = PyUnicode_FromFormat( |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2012 "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
|
2013 uself->start, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2014 uself->end-1, |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2015 reason_str |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2016 ); |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2017 } |
|
59111
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2018 done: |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2019 Py_XDECREF(reason_str); |
|
c8ef906b11b8
Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
54770
diff
changeset
|
2020 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
|
2021 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2022 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2023 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
|
2024 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
|
2025 "UnicodeTranslateError", |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2026 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
|
2027 (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
|
2028 (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
|
2029 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
|
2030 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
|
2031 (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
|
2032 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
|
2033 (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
|
2034 }; |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2035 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
|
2036 |
| 72475 | 2037 /* Deprecated. */ |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2038 PyObject * |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2039 PyUnicodeTranslateError_Create( |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2040 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
|
2041 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
|
2042 { |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2043 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
|
2044 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
|
2045 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2046 |
| 72475 | 2047 PyObject * |
| 2048 _PyUnicodeTranslateError_Create( | |
| 2049 PyObject *object, | |
| 2050 Py_ssize_t start, Py_ssize_t end, const char *reason) | |
| 2051 { | |
| 2052 return PyObject_CallFunction(PyExc_UnicodeTranslateError, "Ons", | |
| 2053 object, start, end, reason); | |
| 2054 } | |
|
38453
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 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2057 * 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
|
2058 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2059 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
|
2060 "Assertion failed."); |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2061 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2062 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2063 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2064 * 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
|
2065 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2066 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
|
2067 "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
|
2068 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2069 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2070 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2071 * 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
|
2072 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2073 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
|
2074 "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
|
2075 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2076 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2077 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2078 * 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
|
2079 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2080 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
|
2081 "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
|
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 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2085 * 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
|
2086 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2087 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
|
2088 "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
|
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 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2092 * 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
|
2093 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2094 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
|
2095 "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
|
2096 "\n" |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2097 "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
|
2098 "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
|
2099 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2100 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2101 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2102 * 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
|
2103 */ |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2104 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
|
2105 "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
|
2106 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2107 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2108 /* |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41940
diff
changeset
|
2109 * 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
|
2110 */ |
|
65690
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2111 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2112 #define MEMERRORS_SAVE 16 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2113 static PyBaseExceptionObject *memerrors_freelist = NULL; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2114 static int memerrors_numfree = 0; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2115 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2116 static PyObject * |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2117 MemoryError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2118 { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2119 PyBaseExceptionObject *self; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2120 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2121 if (type != (PyTypeObject *) PyExc_MemoryError) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2122 return BaseException_new(type, args, kwds); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2123 if (memerrors_freelist == NULL) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2124 return BaseException_new(type, args, kwds); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2125 /* Fetch object from freelist and revive it */ |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2126 self = memerrors_freelist; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2127 self->args = PyTuple_New(0); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2128 /* 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
|
2129 if (self->args == NULL) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2130 return NULL; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2131 memerrors_freelist = (PyBaseExceptionObject *) self->dict; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2132 memerrors_numfree--; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2133 self->dict = NULL; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2134 _Py_NewReference((PyObject *)self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2135 _PyObject_GC_TRACK(self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2136 return (PyObject *)self; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2137 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2138 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2139 static void |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2140 MemoryError_dealloc(PyBaseExceptionObject *self) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2141 { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2142 _PyObject_GC_UNTRACK(self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2143 BaseException_clear(self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2144 if (memerrors_numfree >= MEMERRORS_SAVE) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2145 Py_TYPE(self)->tp_free((PyObject *)self); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2146 else { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2147 self->dict = (PyObject *) memerrors_freelist; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2148 memerrors_freelist = self; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2149 memerrors_numfree++; |
|
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 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2153 static void |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2154 preallocate_memerrors(void) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2155 { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2156 /* 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
|
2157 up the freelist. */ |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2158 int i; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2159 PyObject *errors[MEMERRORS_SAVE]; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2160 for (i = 0; i < MEMERRORS_SAVE; i++) { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2161 errors[i] = MemoryError_new((PyTypeObject *) PyExc_MemoryError, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2162 NULL, NULL); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2163 if (!errors[i]) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2164 Py_FatalError("Could not preallocate MemoryError object"); |
|
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 for (i = 0; i < MEMERRORS_SAVE; i++) { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2167 Py_DECREF(errors[i]); |
|
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 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2170 |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2171 static void |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2172 free_preallocated_memerrors(void) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2173 { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2174 while (memerrors_freelist != NULL) { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2175 PyObject *self = (PyObject *) memerrors_freelist; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2176 memerrors_freelist = (PyBaseExceptionObject *) memerrors_freelist->dict; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2177 Py_TYPE(self)->tp_free((PyObject *)self); |
|
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 } |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2180 |
|
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 static PyTypeObject _PyExc_MemoryError = { |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2183 PyVarObject_HEAD_INIT(NULL, 0) |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2184 "MemoryError", |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2185 sizeof(PyBaseExceptionObject), |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2186 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
|
2187 0, 0, 0, 0, 0, 0, 0, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2188 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
|
2189 PyDoc_STR("Out of memory."), (traverseproc)BaseException_traverse, |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2190 (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
|
2191 0, 0, 0, offsetof(PyBaseExceptionObject, dict), |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2192 (initproc)BaseException_init, 0, MemoryError_new |
|
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 PyObject *PyExc_MemoryError = (PyObject *) &_PyExc_MemoryError; |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2195 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2196 |
|
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
|
2197 /* |
|
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
|
2198 * 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
|
2199 */ |
|
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
|
2200 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
|
2201 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2202 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2203 /* 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
|
2204 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2205 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2206 * 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
|
2207 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2208 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
|
2209 "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
|
2210 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2211 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2212 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2213 * 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
|
2214 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2215 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
|
2216 "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
|
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 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2220 * 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
|
2221 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2222 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
|
2223 "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
|
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 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2227 * 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
|
2228 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2229 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
|
2230 "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
|
2231 "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
|
2232 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2233 |
|
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 * 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
|
2236 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2237 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
|
2238 "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
|
2239 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2240 |
|
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 * 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
|
2243 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2244 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
|
2245 "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
|
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 /* |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2249 * 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
|
2250 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2251 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
|
2252 "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
|
2253 "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
|
2254 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2255 |
|
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 * 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
|
2258 */ |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2259 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
|
2260 "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
|
2261 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2262 |
|
39610
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2263 /* |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2264 * 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
|
2265 */ |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2266 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
|
2267 "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
|
2268 "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
|
2269 |
|
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
|
2270 |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2271 /* |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2272 * BytesWarning extends Warning |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2273 */ |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2274 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
|
2275 "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
|
2276 "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
|
2277 |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43696
diff
changeset
|
2278 |
|
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
|
2279 /* |
|
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
|
2280 * 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
|
2281 */ |
|
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
|
2282 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
|
2283 "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
|
2284 |
|
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
|
2285 |
|
39610
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
2286 |
|
43292
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2287 /* 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
|
2288 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
|
2289 depth will cause its own infinite recursion. |
|
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2290 */ |
|
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2291 PyObject *PyExc_RecursionErrorInst = NULL; |
|
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2292 |
|
74506
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2293 #define PRE_INIT(TYPE) \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2294 if (!(_PyExc_ ## TYPE.tp_flags & Py_TPFLAGS_READY)) { \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2295 if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2296 Py_FatalError("exceptions bootstrapping error."); \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2297 Py_INCREF(PyExc_ ## TYPE); \ |
|
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2298 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2299 |
|
74506
5ffa409af22e
Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents:
74498
diff
changeset
|
2300 #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
|
2301 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
|
2302 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
|
2303 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2304 #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
|
2305 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
|
2306 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
|
2307 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
|
2308 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
|
2309 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2310 #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
|
2311 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
|
2312 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
|
2313 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
|
2314 Py_FatalError("errmap insertion problem."); \ |
|
74508
29a28018e567
Fix some of the remaining test_capi refleaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74507
diff
changeset
|
2315 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
|
2316 } |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2317 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2318 #ifdef MS_WINDOWS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2319 #include <Winsock2.h> |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2320 #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
|
2321 #define EALREADY WSAEALREADY |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2322 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2323 #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
|
2324 #define ECONNABORTED WSAECONNABORTED |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2325 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2326 #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
|
2327 #define ECONNREFUSED WSAECONNREFUSED |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2328 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2329 #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
|
2330 #define ECONNRESET WSAECONNRESET |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2331 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2332 #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
|
2333 #define EINPROGRESS WSAEINPROGRESS |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2334 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2335 #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
|
2336 #define ESHUTDOWN WSAESHUTDOWN |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2337 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2338 #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
|
2339 #define ETIMEDOUT WSAETIMEDOUT |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2340 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2341 #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
|
2342 #define EWOULDBLOCK WSAEWOULDBLOCK |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2343 #endif |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2344 #endif /* MS_WINDOWS */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
2345 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47301
diff
changeset
|
2346 void |
|
76303
2dd046be2c88
Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents:
76272
diff
changeset
|
2347 _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
|
2348 { |
|
76303
2dd046be2c88
Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents:
76272
diff
changeset
|
2349 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
|
2350 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2351 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
|
2352 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
|
2353 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
|
2354 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
|
2355 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
|
2356 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
|
2357 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
|
2358 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
|
2359 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
|
2360 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
|
2361 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
|
2362 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
|
2363 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
|
2364 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
|
2365 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
|
2366 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
|
2367 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
|
2368 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
|
2369 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
|
2370 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
|
2371 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
|
2372 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
|
2373 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
|
2374 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
|
2375 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
|
2376 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
|
2377 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
|
2378 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
|
2379 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
|
2380 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
|
2381 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
|
2382 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
|
2383 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
|
2384 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
|
2385 PRE_INIT(MemoryError) |
|
48437
fa34088380f9
#3295 actually define PyExc_BufferError
Benjamin Peterson <benjamin@python.org>
parents:
47580
diff
changeset
|
2386 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
|
2387 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
|
2388 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
|
2389 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
|
2390 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
|
2391 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
|
2392 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
|
2393 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
|
2394 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
|
2395 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
|
2396 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
|
2397 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
|
2398 |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2399 /* OSError subclasses */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2400 PRE_INIT(ConnectionError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2401 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2402 PRE_INIT(BlockingIOError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2403 PRE_INIT(BrokenPipeError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2404 PRE_INIT(ChildProcessError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2405 PRE_INIT(ConnectionAbortedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2406 PRE_INIT(ConnectionRefusedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2407 PRE_INIT(ConnectionResetError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2408 PRE_INIT(FileExistsError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2409 PRE_INIT(FileNotFoundError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2410 PRE_INIT(IsADirectoryError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2411 PRE_INIT(NotADirectoryError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2412 PRE_INIT(InterruptedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2413 PRE_INIT(PermissionError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2414 PRE_INIT(ProcessLookupError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2415 PRE_INIT(TimeoutError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2416 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2417 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
|
2418 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
|
2419 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
|
2420 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2421 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
|
2422 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
|
2423 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
|
2424 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
|
2425 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
|
2426 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
|
2427 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
|
2428 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
|
2429 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
|
2430 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
|
2431 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
|
2432 #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
|
2433 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
|
2434 #endif |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2435 #ifdef __VMS |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2436 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
|
2437 #endif |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2438 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
|
2439 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
|
2440 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
|
2441 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
|
2442 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
|
2443 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
|
2444 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
|
2445 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
|
2446 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
|
2447 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
|
2448 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
|
2449 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
|
2450 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
|
2451 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
|
2452 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
|
2453 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
|
2454 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
|
2455 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
|
2456 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
|
2457 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
|
2458 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
|
2459 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
|
2460 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
|
2461 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
|
2462 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
|
2463 POST_INIT(MemoryError) |
|
48437
fa34088380f9
#3295 actually define PyExc_BufferError
Benjamin Peterson <benjamin@python.org>
parents:
47580
diff
changeset
|
2464 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
|
2465 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
|
2466 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
|
2467 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
|
2468 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
|
2469 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
|
2470 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
|
2471 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
|
2472 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
|
2473 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
|
2474 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
|
2475 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
|
2476 |
|
74509
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2477 if (!errnomap) { |
|
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2478 errnomap = PyDict_New(); |
|
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2479 if (!errnomap) |
|
44d8aa3c1003
Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents:
74508
diff
changeset
|
2480 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
|
2481 } |
|
72879
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2482 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2483 /* OSError subclasses */ |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2484 POST_INIT(ConnectionError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2485 |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2486 POST_INIT(BlockingIOError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2487 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
|
2488 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
|
2489 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
|
2490 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
|
2491 POST_INIT(BrokenPipeError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2492 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
|
2493 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
|
2494 POST_INIT(ChildProcessError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2495 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
|
2496 POST_INIT(ConnectionAbortedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2497 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
|
2498 POST_INIT(ConnectionRefusedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2499 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
|
2500 POST_INIT(ConnectionResetError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2501 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
|
2502 POST_INIT(FileExistsError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2503 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
|
2504 POST_INIT(FileNotFoundError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2505 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
|
2506 POST_INIT(IsADirectoryError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2507 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
|
2508 POST_INIT(NotADirectoryError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2509 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
|
2510 POST_INIT(InterruptedError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2511 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
|
2512 POST_INIT(PermissionError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2513 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
|
2514 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
|
2515 POST_INIT(ProcessLookupError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2516 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
|
2517 POST_INIT(TimeoutError); |
|
41a1de81ef2b
PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents:
72703
diff
changeset
|
2518 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
|
2519 |
|
65690
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2520 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
|
2521 |
|
74498
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2522 if (!PyExc_RecursionErrorInst) { |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2523 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
|
2524 if (!PyExc_RecursionErrorInst) |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2525 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
|
2526 "recursion errors"); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2527 else { |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2528 PyBaseExceptionObject *err_inst = |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2529 (PyBaseExceptionObject *)PyExc_RecursionErrorInst; |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2530 PyObject *args_tuple; |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2531 PyObject *exc_message; |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2532 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
|
2533 if (!exc_message) |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2534 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
|
2535 "pre-allocation"); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2536 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
|
2537 if (!args_tuple) |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2538 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
|
2539 "pre-allocation"); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2540 Py_DECREF(exc_message); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2541 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
|
2542 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
|
2543 Py_DECREF(args_tuple); |
|
ab5b47bf6711
Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents:
68257
diff
changeset
|
2544 } |
|
43292
876b7ef4775d
Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
43188
diff
changeset
|
2545 } |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2546 } |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2547 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2548 void |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2549 _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
|
2550 { |
|
65690
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2551 Py_CLEAR(PyExc_RecursionErrorInst); |
|
c6d86439aa91
Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
62448
diff
changeset
|
2552 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
|
2553 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
|
2554 } |
