annotate Objects/exceptions.c @ 84007:dbfbdf2b5c19 3.3

Fix #17967: For ftp urls CWD to target instead of hopping to each directory towards target. This fixes a bug where target is accessible, but parent directories are restricted.
author Senthil Kumaran <senthil@uthcode.com>
date Sat, 01 Jun 2013 08:27:06 -0700
parents 67c27421b00b
children 58fcd81acfb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1 /*
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
2 * New exceptions.c written in Iceland by Richard Jones and Georg Brandl.
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
3 *
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
4 * Thanks go to Tim Peters and Michael Hudson for debugging.
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
5 */
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
6
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
7 #define PY_SSIZE_T_CLEAN
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
8 #include <Python.h>
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
9 #include "structmember.h"
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
10 #include "osdefs.h"
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
11
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
12
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
13 /* Compatibility aliases */
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
14 PyObject *PyExc_EnvironmentError = NULL;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
15 PyObject *PyExc_IOError = NULL;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
16 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
17 PyObject *PyExc_WindowsError = NULL;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
18 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
19 #ifdef __VMS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
20 PyObject *PyExc_VMSError = NULL;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
21 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
22
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
23 /* The dict map from errno codes to OSError subclasses */
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
24 static PyObject *errnomap = NULL;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
25
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
26
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
27 /* NOTE: If the exception class hierarchy changes, don't forget to update
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
28 * Lib/test/exception_hierarchy.txt
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
29 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
30
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
31 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
32 * BaseException
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
33 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
34 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
35 BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
36 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
37 PyBaseExceptionObject *self;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
38
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
39 self = (PyBaseExceptionObject *)type->tp_alloc(type, 0);
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41501
diff changeset
40 if (!self)
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41501
diff changeset
41 return NULL;
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
42 /* the dict is created on the fly in PyObject_GenericSetAttr */
41749
b085eb66b7f6 Merged revisions 55342-55406 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41716
diff changeset
43 self->dict = NULL;
43188
386c22d93ab6 Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents: 43102
diff changeset
44 self->traceback = self->cause = self->context = NULL;
76942
b0eb7d2a9542 PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents: 76898
diff changeset
45 self->suppress_context = 0;
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
46
82413
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
47 if (args) {
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
48 self->args = args;
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
49 Py_INCREF(args);
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
50 return (PyObject *)self;
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
51 }
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
52
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
53 self->args = PyTuple_New(0);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
54 if (!self->args) {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
55 Py_DECREF(self);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
56 return NULL;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
57 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
58
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
59 return (PyObject *)self;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
60 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
61
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
62 static int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
63 BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
64 {
82413
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
65 PyObject *tmp;
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
66
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44158
diff changeset
67 if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
68 return -1;
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
69
82413
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
70 tmp = self->args;
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
71 self->args = args;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
72 Py_INCREF(self->args);
82413
2c9f7ed28384 #17296: backport fix for issue 1692335, naive exception pickling.
R David Murray <rdmurray@bitdance.com>
parents: 74864
diff changeset
73 Py_XDECREF(tmp);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
74
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
75 return 0;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
76 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
77
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
78 static int
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
79 BaseException_clear(PyBaseExceptionObject *self)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
80 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
81 Py_CLEAR(self->dict);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
82 Py_CLEAR(self->args);
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
83 Py_CLEAR(self->traceback);
43188
386c22d93ab6 Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents: 43102
diff changeset
84 Py_CLEAR(self->cause);
386c22d93ab6 Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents: 43102
diff changeset
85 Py_CLEAR(self->context);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
86 return 0;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
87 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
88
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
89 static void
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
90 BaseException_dealloc(PyBaseExceptionObject *self)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
91 {
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39610
diff changeset
92 _PyObject_GC_UNTRACK(self);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
93 BaseException_clear(self);
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44158
diff changeset
94 Py_TYPE(self)->tp_free((PyObject *)self);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
95 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
96
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
97 static int
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
98 BaseException_traverse(PyBaseExceptionObject *self, visitproc visit, void *arg)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
99 {
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
100 Py_VISIT(self->dict);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
101 Py_VISIT(self->args);
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
102 Py_VISIT(self->traceback);
43188
386c22d93ab6 Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents: 43102
diff changeset
103 Py_VISIT(self->cause);
386c22d93ab6 Fix refleaks exposed by test_raise.
Collin Winter <collinw@gmail.com>
parents: 43102
diff changeset
104 Py_VISIT(self->context);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
105 return 0;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
106 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
107
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
108 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
109 BaseException_str(PyBaseExceptionObject *self)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
110 {
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
111 switch (PyTuple_GET_SIZE(self->args)) {
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
112 case 0:
41882
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
113 return PyUnicode_FromString("");
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
114 case 1:
43866
8ed0280c2ab6 Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
Thomas Heller <theller@ctypes.org>
parents: 43777
diff changeset
115 return PyObject_Str(PyTuple_GET_ITEM(self->args, 0));
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
116 default:
43866
8ed0280c2ab6 Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
Thomas Heller <theller@ctypes.org>
parents: 43777
diff changeset
117 return PyObject_Str(self->args);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
118 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
119 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
120
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
121 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
122 BaseException_repr(PyBaseExceptionObject *self)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
123 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
124 char *name;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
125 char *dot;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
126
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
127 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
128 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
129 if (dot != NULL) name = dot+1;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
130
41782
bee8d01ef42c Add a format specifier %R to PyUnicode_FromFormat(), which embeds
Walter Dörwald <walter@livinglogic.de>
parents: 41769
diff changeset
131 return PyUnicode_FromFormat("%s%R", name, self->args);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
132 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
133
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
134 /* Pickling support */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
135 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
136 BaseException_reduce(PyBaseExceptionObject *self)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
137 {
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
138 if (self->args && self->dict)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44158
diff changeset
139 return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict);
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
140 else
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44158
diff changeset
141 return PyTuple_Pack(2, Py_TYPE(self), self->args);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
142 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
143
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
144 /*
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
145 * Needed for backward compatibility, since exceptions used to store
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
146 * all their attributes in the __dict__. Code is taken from cPickle's
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
147 * load_build function.
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
148 */
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
149 static PyObject *
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
150 BaseException_setstate(PyObject *self, PyObject *state)
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
151 {
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
152 PyObject *d_key, *d_value;
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
153 Py_ssize_t i = 0;
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
154
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
155 if (state != Py_None) {
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
156 if (!PyDict_Check(state)) {
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
157 PyErr_SetString(PyExc_TypeError, "state is not a dictionary");
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
158 return NULL;
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
159 }
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
160 while (PyDict_Next(state, &i, &d_key, &d_value)) {
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
161 if (PyObject_SetAttr(self, d_key, d_value) < 0)
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
162 return NULL;
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
163 }
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
164 }
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
165 Py_RETURN_NONE;
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
166 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
167
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
168 static PyObject *
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
169 BaseException_with_traceback(PyObject *self, PyObject *tb) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
170 if (PyException_SetTraceback(self, tb))
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
171 return NULL;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
172
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
173 Py_INCREF(self);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
174 return self;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
175 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
176
46682
91d5f0841700 Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents: 44351
diff changeset
177 PyDoc_STRVAR(with_traceback_doc,
91d5f0841700 Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents: 44351
diff changeset
178 "Exception.with_traceback(tb) --\n\
91d5f0841700 Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents: 44351
diff changeset
179 set self.__traceback__ to tb and return self.");
91d5f0841700 Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents: 44351
diff changeset
180
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
181
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
182 static PyMethodDef BaseException_methods[] = {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
183 {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS },
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
184 {"__setstate__", (PyCFunction)BaseException_setstate, METH_O },
46682
91d5f0841700 Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents: 44351
diff changeset
185 {"with_traceback", (PyCFunction)BaseException_with_traceback, METH_O,
91d5f0841700 Give with_traceback a docstring.
Georg Brandl <georg@python.org>
parents: 44351
diff changeset
186 with_traceback_doc},
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
187 {NULL, NULL, 0, NULL},
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
188 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
189
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
190 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
191 BaseException_get_args(PyBaseExceptionObject *self)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
192 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
193 if (self->args == NULL) {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
194 Py_INCREF(Py_None);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
195 return Py_None;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
196 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
197 Py_INCREF(self->args);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
198 return self->args;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
199 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
200
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
201 static int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
202 BaseException_set_args(PyBaseExceptionObject *self, PyObject *val)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
203 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
204 PyObject *seq;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
205 if (val == NULL) {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
206 PyErr_SetString(PyExc_TypeError, "args may not be deleted");
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
207 return -1;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
208 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
209 seq = PySequence_Tuple(val);
74752
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
210 if (!seq)
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
211 return -1;
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
212 Py_CLEAR(self->args);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
213 self->args = seq;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
214 return 0;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
215 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
216
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
217 static PyObject *
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
218 BaseException_get_tb(PyBaseExceptionObject *self)
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
219 {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
220 if (self->traceback == NULL) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
221 Py_INCREF(Py_None);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
222 return Py_None;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
223 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
224 Py_INCREF(self->traceback);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
225 return self->traceback;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
226 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
227
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
228 static int
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
229 BaseException_set_tb(PyBaseExceptionObject *self, PyObject *tb)
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
230 {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
231 if (tb == NULL) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
232 PyErr_SetString(PyExc_TypeError, "__traceback__ may not be deleted");
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
233 return -1;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
234 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
235 else if (!(tb == Py_None || PyTraceBack_Check(tb))) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
236 PyErr_SetString(PyExc_TypeError,
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
237 "__traceback__ must be a traceback or None");
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
238 return -1;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
239 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
240
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
241 Py_XINCREF(tb);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
242 Py_XDECREF(self->traceback);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
243 self->traceback = tb;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
244 return 0;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
245 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
246
52509
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
247 static PyObject *
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
248 BaseException_get_context(PyObject *self) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
249 PyObject *res = PyException_GetContext(self);
74752
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
250 if (res)
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
251 return res; /* new reference already returned above */
52509
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
252 Py_RETURN_NONE;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
253 }
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
254
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
255 static int
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
256 BaseException_set_context(PyObject *self, PyObject *arg) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
257 if (arg == NULL) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
258 PyErr_SetString(PyExc_TypeError, "__context__ may not be deleted");
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
259 return -1;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
260 } else if (arg == Py_None) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
261 arg = NULL;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
262 } else if (!PyExceptionInstance_Check(arg)) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
263 PyErr_SetString(PyExc_TypeError, "exception context must be None "
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
264 "or derive from BaseException");
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
265 return -1;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
266 } else {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
267 /* PyException_SetContext steals this reference */
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
268 Py_INCREF(arg);
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 59128
diff changeset
269 }
52509
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
270 PyException_SetContext(self, arg);
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
271 return 0;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
272 }
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
273
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
274 static PyObject *
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
275 BaseException_get_cause(PyObject *self) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
276 PyObject *res = PyException_GetCause(self);
74752
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
277 if (res)
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
278 return res; /* new reference already returned above */
52509
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
279 Py_RETURN_NONE;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
280 }
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
281
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
282 static int
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
283 BaseException_set_cause(PyObject *self, PyObject *arg) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
284 if (arg == NULL) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
285 PyErr_SetString(PyExc_TypeError, "__cause__ may not be deleted");
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
286 return -1;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
287 } else if (arg == Py_None) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
288 arg = NULL;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
289 } else if (!PyExceptionInstance_Check(arg)) {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
290 PyErr_SetString(PyExc_TypeError, "exception cause must be None "
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
291 "or derive from BaseException");
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
292 return -1;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
293 } else {
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
294 /* PyException_SetCause steals this reference */
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
295 Py_INCREF(arg);
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 59128
diff changeset
296 }
52509
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
297 PyException_SetCause(self, arg);
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
298 return 0;
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
299 }
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
300
41716
00c02c4488ce Merged revisions 55325-55327 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41611
diff changeset
301
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
302 static PyGetSetDef BaseException_getset[] = {
75051
f029312764b4 use new generic __dict__ descriptor implementations
Benjamin Peterson <benjamin@python.org>
parents: 74865
diff changeset
303 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
304 {"args", (getter)BaseException_get_args, (setter)BaseException_set_args},
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
305 {"__traceback__", (getter)BaseException_get_tb, (setter)BaseException_set_tb},
52509
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
306 {"__context__", (getter)BaseException_get_context,
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
307 (setter)BaseException_set_context, PyDoc_STR("exception context")},
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
308 {"__cause__", (getter)BaseException_get_cause,
d12b02abe6dc Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
Georg Brandl <georg@python.org>
parents: 51579
diff changeset
309 (setter)BaseException_set_cause, PyDoc_STR("exception cause")},
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
310 {NULL},
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
311 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
312
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
313
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
314 PyObject *
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
315 PyException_GetTraceback(PyObject *self) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
316 PyBaseExceptionObject *base_self = (PyBaseExceptionObject *)self;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
317 Py_XINCREF(base_self->traceback);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
318 return base_self->traceback;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
319 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
320
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
321
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
322 int
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
323 PyException_SetTraceback(PyObject *self, PyObject *tb) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
324 return BaseException_set_tb((PyBaseExceptionObject *)self, tb);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
325 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
326
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
327 PyObject *
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
328 PyException_GetCause(PyObject *self) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
329 PyObject *cause = ((PyBaseExceptionObject *)self)->cause;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
330 Py_XINCREF(cause);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
331 return cause;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
332 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
333
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
334 /* Steals a reference to cause */
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
335 void
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
336 PyException_SetCause(PyObject *self, PyObject *cause) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
337 PyObject *old_cause = ((PyBaseExceptionObject *)self)->cause;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
338 ((PyBaseExceptionObject *)self)->cause = cause;
76942
b0eb7d2a9542 PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents: 76898
diff changeset
339 ((PyBaseExceptionObject *)self)->suppress_context = 1;
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
340 Py_XDECREF(old_cause);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
341 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
342
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
343 PyObject *
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
344 PyException_GetContext(PyObject *self) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
345 PyObject *context = ((PyBaseExceptionObject *)self)->context;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
346 Py_XINCREF(context);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
347 return context;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
348 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
349
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
350 /* Steals a reference to context */
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
351 void
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
352 PyException_SetContext(PyObject *self, PyObject *context) {
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
353 PyObject *old_context = ((PyBaseExceptionObject *)self)->context;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
354 ((PyBaseExceptionObject *)self)->context = context;
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
355 Py_XDECREF(old_context);
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
356 }
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
357
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42855
diff changeset
358
76942
b0eb7d2a9542 PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents: 76898
diff changeset
359 static struct PyMemberDef BaseException_members[] = {
b0eb7d2a9542 PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents: 76898
diff changeset
360 {"__suppress_context__", T_BOOL,
76988
1ecd10260649 Fix build failure.
Antoine Pitrou <solipsis@pitrou.net>
parents: 76942
diff changeset
361 offsetof(PyBaseExceptionObject, suppress_context)},
1ecd10260649 Fix build failure.
Antoine Pitrou <solipsis@pitrou.net>
parents: 76942
diff changeset
362 {NULL}
76942
b0eb7d2a9542 PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents: 76898
diff changeset
363 };
b0eb7d2a9542 PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents: 76898
diff changeset
364
b0eb7d2a9542 PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents: 76898
diff changeset
365
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
366 static PyTypeObject _PyExc_BaseException = {
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 42305
diff changeset
367 PyVarObject_HEAD_INIT(NULL, 0)
40949
e759fd8d95ae Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents: 40909
diff changeset
368 "BaseException", /*tp_name*/
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
369 sizeof(PyBaseExceptionObject), /*tp_basicsize*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
370 0, /*tp_itemsize*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
371 (destructor)BaseException_dealloc, /*tp_dealloc*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
372 0, /*tp_print*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
373 0, /*tp_getattr*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
374 0, /*tp_setattr*/
51271
87fbbf22adf3 Merged revisions 69214 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50886
diff changeset
375 0, /* tp_reserved; */
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
376 (reprfunc)BaseException_repr, /*tp_repr*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
377 0, /*tp_as_number*/
40959
0ea52558bdfe Remove the ability to slice/index on exceptions per PEP 352.
Brett Cannon <bcannon@gmail.com>
parents: 40949
diff changeset
378 0, /*tp_as_sequence*/
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
379 0, /*tp_as_mapping*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
380 0, /*tp_hash */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
381 0, /*tp_call*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
382 (reprfunc)BaseException_str, /*tp_str*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
383 PyObject_GenericGetAttr, /*tp_getattro*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
384 PyObject_GenericSetAttr, /*tp_setattro*/
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
385 0, /*tp_as_buffer*/
40909
f2f0b41f270d Merged revisions 53875-53911 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40626
diff changeset
386 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 59128
diff changeset
387 Py_TPFLAGS_BASE_EXC_SUBCLASS, /*tp_flags*/
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
388 PyDoc_STR("Common base class for all exceptions"), /* tp_doc */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
389 (traverseproc)BaseException_traverse, /* tp_traverse */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
390 (inquiry)BaseException_clear, /* tp_clear */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
391 0, /* tp_richcompare */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
392 0, /* tp_weaklistoffset */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
393 0, /* tp_iter */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
394 0, /* tp_iternext */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
395 BaseException_methods, /* tp_methods */
76942
b0eb7d2a9542 PEP 415: Implement suppression of __context__ display with an exception attribute
Benjamin Peterson <benjamin@python.org>
parents: 76898
diff changeset
396 BaseException_members, /* tp_members */
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
397 BaseException_getset, /* tp_getset */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
398 0, /* tp_base */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
399 0, /* tp_dict */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
400 0, /* tp_descr_get */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
401 0, /* tp_descr_set */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
402 offsetof(PyBaseExceptionObject, dict), /* tp_dictoffset */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
403 (initproc)BaseException_init, /* tp_init */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
404 0, /* tp_alloc */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
405 BaseException_new, /* tp_new */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
406 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
407 /* the CPython API expects exceptions to be (PyObject *) - both a hold-over
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
408 from the previous implmentation and also allowing Python objects to be used
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
409 in the API */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
410 PyObject *PyExc_BaseException = (PyObject *)&_PyExc_BaseException;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
411
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
412 /* note these macros omit the last semicolon so the macro invocation may
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
413 * include it and not look strange.
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
414 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
415 #define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC) \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
416 static PyTypeObject _PyExc_ ## EXCNAME = { \
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 42305
diff changeset
417 PyVarObject_HEAD_INIT(NULL, 0) \
40949
e759fd8d95ae Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents: 40909
diff changeset
418 # EXCNAME, \
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
419 sizeof(PyBaseExceptionObject), \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
420 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
421 0, 0, 0, 0, 0, 0, 0, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
422 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
423 PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
424 (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
425 0, 0, 0, offsetof(PyBaseExceptionObject, dict), \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
426 (initproc)BaseException_init, 0, BaseException_new,\
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
427 }; \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
428 PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
429
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
430 #define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC) \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
431 static PyTypeObject _PyExc_ ## EXCNAME = { \
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 42305
diff changeset
432 PyVarObject_HEAD_INIT(NULL, 0) \
40949
e759fd8d95ae Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents: 40909
diff changeset
433 # EXCNAME, \
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
434 sizeof(Py ## EXCSTORE ## Object), \
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
435 0, (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
436 0, 0, 0, 0, 0, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
437 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
438 PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
439 (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
440 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
441 (initproc)EXCSTORE ## _init, 0, 0, \
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
442 }; \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
443 PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
444
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
445 #define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCNEW, \
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
446 EXCMETHODS, EXCMEMBERS, EXCGETSET, \
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
447 EXCSTR, EXCDOC) \
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
448 static PyTypeObject _PyExc_ ## EXCNAME = { \
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 42305
diff changeset
449 PyVarObject_HEAD_INIT(NULL, 0) \
40949
e759fd8d95ae Remove the exceptions builtin module, all the exceptions are already builtin.
Neal Norwitz <nnorwitz@gmail.com>
parents: 40909
diff changeset
450 # EXCNAME, \
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
451 sizeof(Py ## EXCSTORE ## Object), 0, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
452 (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
453 (reprfunc)EXCSTR, 0, 0, 0, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
454 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
455 PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
456 (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, EXCMETHODS, \
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
457 EXCMEMBERS, EXCGETSET, &_ ## EXCBASE, \
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
458 0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
459 (initproc)EXCSTORE ## _init, 0, EXCNEW,\
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
460 }; \
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
461 PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
462
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
463
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
464 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
465 * Exception extends BaseException
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
466 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
467 SimpleExtendsException(PyExc_BaseException, Exception,
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
468 "Common base class for all non-exit exceptions.");
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
469
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
470
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
471 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
472 * TypeError extends Exception
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
473 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
474 SimpleExtendsException(PyExc_Exception, TypeError,
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
475 "Inappropriate argument type.");
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
476
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
477
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
478 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
479 * StopIteration extends Exception
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
480 */
74356
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
481
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
482 static PyMemberDef StopIteration_members[] = {
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
483 {"value", T_OBJECT, offsetof(PyStopIterationObject, value), 0,
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
484 PyDoc_STR("generator return value")},
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
485 {NULL} /* Sentinel */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
486 };
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
487
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
488 static int
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
489 StopIteration_init(PyStopIterationObject *self, PyObject *args, PyObject *kwds)
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
490 {
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
491 Py_ssize_t size = PyTuple_GET_SIZE(args);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
492 PyObject *value;
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
493
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
494 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
495 return -1;
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
496 Py_CLEAR(self->value);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
497 if (size > 0)
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
498 value = PyTuple_GET_ITEM(args, 0);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
499 else
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
500 value = Py_None;
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
501 Py_INCREF(value);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
502 self->value = value;
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
503 return 0;
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
504 }
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
505
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
506 static int
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
507 StopIteration_clear(PyStopIterationObject *self)
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
508 {
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
509 Py_CLEAR(self->value);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
510 return BaseException_clear((PyBaseExceptionObject *)self);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
511 }
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
512
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
513 static void
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
514 StopIteration_dealloc(PyStopIterationObject *self)
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
515 {
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
516 _PyObject_GC_UNTRACK(self);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
517 StopIteration_clear(self);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
518 Py_TYPE(self)->tp_free((PyObject *)self);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
519 }
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
520
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
521 static int
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
522 StopIteration_traverse(PyStopIterationObject *self, visitproc visit, void *arg)
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
523 {
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
524 Py_VISIT(self->value);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
525 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
526 }
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
527
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
528 ComplexExtendsException(
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
529 PyExc_Exception, /* base */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
530 StopIteration, /* name */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
531 StopIteration, /* prefix for *_init, etc */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
532 0, /* new */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
533 0, /* methods */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
534 StopIteration_members, /* members */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
535 0, /* getset */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
536 0, /* str */
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
537 "Signal the end from iterator.__next__()."
d64ac9ab4cd0 Implement PEP 380 - 'yield from' (closes #11682)
Nick Coghlan <ncoghlan@gmail.com>
parents: 73981
diff changeset
538 );
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
539
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
540
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
541 /*
44129
b637349336fd Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44125
diff changeset
542 * GeneratorExit extends BaseException
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
543 */
44129
b637349336fd Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44125
diff changeset
544 SimpleExtendsException(PyExc_BaseException, GeneratorExit,
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
545 "Request that a generator exit.");
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
546
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
547
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
548 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
549 * SystemExit extends BaseException
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
550 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
551
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
552 static int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
553 SystemExit_init(PySystemExitObject *self, PyObject *args, PyObject *kwds)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
554 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
555 Py_ssize_t size = PyTuple_GET_SIZE(args);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
556
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
557 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
558 return -1;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
559
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
560 if (size == 0)
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
561 return 0;
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
562 Py_CLEAR(self->code);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
563 if (size == 1)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
564 self->code = PyTuple_GET_ITEM(args, 0);
70403
772d9825f154 SystemExit_init(): avoid an useless test
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257
diff changeset
565 else /* size > 1 */
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
566 self->code = args;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
567 Py_INCREF(self->code);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
568 return 0;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
569 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
570
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
571 static int
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
572 SystemExit_clear(PySystemExitObject *self)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
573 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
574 Py_CLEAR(self->code);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
575 return BaseException_clear((PyBaseExceptionObject *)self);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
576 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
577
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
578 static void
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
579 SystemExit_dealloc(PySystemExitObject *self)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
580 {
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39610
diff changeset
581 _PyObject_GC_UNTRACK(self);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
582 SystemExit_clear(self);
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44158
diff changeset
583 Py_TYPE(self)->tp_free((PyObject *)self);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
584 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
585
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
586 static int
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
587 SystemExit_traverse(PySystemExitObject *self, visitproc visit, void *arg)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
588 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
589 Py_VISIT(self->code);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
590 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
591 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
592
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
593 static PyMemberDef SystemExit_members[] = {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
594 {"code", T_OBJECT, offsetof(PySystemExitObject, code), 0,
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
595 PyDoc_STR("exception code")},
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
596 {NULL} /* Sentinel */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
597 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
598
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
599 ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit,
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
600 0, 0, SystemExit_members, 0, 0,
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
601 "Request to exit from the interpreter.");
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
602
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
603 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
604 * KeyboardInterrupt extends BaseException
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
605 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
606 SimpleExtendsException(PyExc_BaseException, KeyboardInterrupt,
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
607 "Program interrupted by user.");
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
608
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
609
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
610 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
611 * ImportError extends Exception
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
612 */
76272
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
613
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
614 static int
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
615 ImportError_init(PyImportErrorObject *self, PyObject *args, PyObject *kwds)
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
616 {
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
617 PyObject *msg = NULL;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
618 PyObject *name = NULL;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
619 PyObject *path = NULL;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
620
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
621 /* Macro replacement doesn't allow ## to start the first line of a macro,
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
622 so we move the assignment and NULL check into the if-statement. */
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
623 #define GET_KWD(kwd) { \
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
624 kwd = PyDict_GetItemString(kwds, #kwd); \
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
625 if (kwd) { \
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
626 Py_CLEAR(self->kwd); \
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
627 self->kwd = kwd; \
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
628 Py_INCREF(self->kwd);\
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
629 if (PyDict_DelItemString(kwds, #kwd)) \
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
630 return -1; \
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
631 } \
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
632 }
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
633
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
634 if (kwds) {
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
635 GET_KWD(name);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
636 GET_KWD(path);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
637 }
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
638
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
639 if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
640 return -1;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
641 if (PyTuple_GET_SIZE(args) != 1)
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
642 return 0;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
643 if (!PyArg_UnpackTuple(args, "ImportError", 1, 1, &msg))
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
644 return -1;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
645
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
646 Py_CLEAR(self->msg); /* replacing */
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
647 self->msg = msg;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
648 Py_INCREF(self->msg);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
649
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
650 return 0;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
651 }
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
652
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
653 static int
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
654 ImportError_clear(PyImportErrorObject *self)
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
655 {
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
656 Py_CLEAR(self->msg);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
657 Py_CLEAR(self->name);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
658 Py_CLEAR(self->path);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
659 return BaseException_clear((PyBaseExceptionObject *)self);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
660 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
661
76272
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
662 static void
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
663 ImportError_dealloc(PyImportErrorObject *self)
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
664 {
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
665 _PyObject_GC_UNTRACK(self);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
666 ImportError_clear(self);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
667 Py_TYPE(self)->tp_free((PyObject *)self);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
668 }
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
669
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
670 static int
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
671 ImportError_traverse(PyImportErrorObject *self, visitproc visit, void *arg)
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
672 {
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
673 Py_VISIT(self->msg);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
674 Py_VISIT(self->name);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
675 Py_VISIT(self->path);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
676 return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
677 }
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
678
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
679 static PyObject *
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
680 ImportError_str(PyImportErrorObject *self)
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
681 {
78737
91909962d7f5 Issue #15778: Coerce ImportError.args to a string when it isn't
Brett Cannon <brett@python.org>
parents: 78304
diff changeset
682 if (self->msg && PyUnicode_CheckExact(self->msg)) {
76272
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
683 Py_INCREF(self->msg);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
684 return self->msg;
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
685 }
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
686 else {
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
687 return BaseException_str((PyBaseExceptionObject *)self);
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
688 }
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
689 }
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
690
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
691 static PyMemberDef ImportError_members[] = {
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
692 {"msg", T_OBJECT, offsetof(PyImportErrorObject, msg), 0,
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
693 PyDoc_STR("exception message")},
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
694 {"name", T_OBJECT, offsetof(PyImportErrorObject, name), 0,
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
695 PyDoc_STR("module name")},
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
696 {"path", T_OBJECT, offsetof(PyImportErrorObject, path), 0,
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
697 PyDoc_STR("module path")},
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
698 {NULL} /* Sentinel */
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
699 };
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
700
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
701 static PyMethodDef ImportError_methods[] = {
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
702 {NULL}
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
703 };
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
704
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
705 ComplexExtendsException(PyExc_Exception, ImportError,
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
706 ImportError, 0 /* new */,
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
707 ImportError_methods, ImportError_members,
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
708 0 /* getset */, ImportError_str,
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
709 "Import can't find module, or can't find name in "
6825fd9b00ed Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Brett Cannon <brett@python.org>
parents: 75292
diff changeset
710 "module.");
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
711
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
712 /*
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
713 * OSError extends Exception
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
714 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
715
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
716 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
717 #include "errmap.h"
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
718 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
719
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
720 /* Where a function has a single filename, such as open() or some
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
721 * of the os module functions, PyErr_SetFromErrnoWithFilename() is
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
722 * called, giving a third argument which is the filename. But, so
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
723 * that old code using in-place unpacking doesn't break, e.g.:
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
724 *
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
725 * except OSError, (errno, strerror):
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
726 *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
727 * we hack args so that it only contains two items. This also
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
728 * means we need our own __str__() which prints out the filename
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
729 * when it was supplied.
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
730 */
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
731
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
732 /* This function doesn't cleanup on error, the caller should */
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
733 static int
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
734 oserror_parse_args(PyObject **p_args,
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
735 PyObject **myerrno, PyObject **strerror,
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
736 PyObject **filename
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
737 #ifdef MS_WINDOWS
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
738 , PyObject **winerror
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
739 #endif
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
740 )
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
741 {
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
742 Py_ssize_t nargs;
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
743 PyObject *args = *p_args;
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
744
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
745 nargs = PyTuple_GET_SIZE(args);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
746
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
747 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
748 if (nargs >= 2 && nargs <= 4) {
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
749 if (!PyArg_UnpackTuple(args, "OSError", 2, 4,
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
750 myerrno, strerror, filename, winerror))
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
751 return -1;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
752 if (*winerror && PyLong_Check(*winerror)) {
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
753 long errcode, winerrcode;
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
754 PyObject *newargs;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
755 Py_ssize_t i;
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
756
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
757 winerrcode = PyLong_AsLong(*winerror);
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
758 if (winerrcode == -1 && PyErr_Occurred())
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
759 return -1;
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
760 /* Set errno to the corresponding POSIX errno (overriding
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
761 first argument). Windows Socket error codes (>= 10000)
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
762 have the same value as their POSIX counterparts.
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
763 */
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
764 if (winerrcode < 10000)
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
765 errcode = winerror_to_errno(winerrcode);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
766 else
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
767 errcode = winerrcode;
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
768 *myerrno = PyLong_FromLong(errcode);
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
769 if (!*myerrno)
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
770 return -1;
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
771 newargs = PyTuple_New(nargs);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
772 if (!newargs)
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
773 return -1;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
774 PyTuple_SET_ITEM(newargs, 0, *myerrno);
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
775 for (i = 1; i < nargs; i++) {
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
776 PyObject *val = PyTuple_GET_ITEM(args, i);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
777 Py_INCREF(val);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
778 PyTuple_SET_ITEM(newargs, i, val);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
779 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
780 Py_DECREF(args);
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
781 args = *p_args = newargs;
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
782 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
783 }
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
784 #else
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
785 if (nargs >= 2 && nargs <= 3) {
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
786 if (!PyArg_UnpackTuple(args, "OSError", 2, 3,
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
787 myerrno, strerror, filename))
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
788 return -1;
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
789 }
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
790 #endif
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
791
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
792 return 0;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
793 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
794
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
795 static int
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
796 oserror_init(PyOSErrorObject *self, PyObject **p_args,
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
797 PyObject *myerrno, PyObject *strerror,
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
798 PyObject *filename
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
799 #ifdef MS_WINDOWS
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
800 , PyObject *winerror
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
801 #endif
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
802 )
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
803 {
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
804 PyObject *args = *p_args;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
805 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
806
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
807 /* self->filename will remain Py_None otherwise */
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
808 if (filename && filename != Py_None) {
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
809 if (Py_TYPE(self) == (PyTypeObject *) PyExc_BlockingIOError &&
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
810 PyNumber_Check(filename)) {
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
811 /* BlockingIOError's 3rd argument can be the number of
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
812 * characters written.
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
813 */
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
814 self->written = PyNumber_AsSsize_t(filename, PyExc_ValueError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
815 if (self->written == -1 && PyErr_Occurred())
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
816 return -1;
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
817 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
818 else {
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
819 Py_INCREF(filename);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
820 self->filename = filename;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
821
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
822 if (nargs >= 2 && nargs <= 3) {
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
823 /* filename is removed from the args tuple (for compatibility
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
824 purposes, see test_exceptions.py) */
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
825 PyObject *subslice = PyTuple_GetSlice(args, 0, 2);
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
826 if (!subslice)
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
827 return -1;
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
828
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
829 Py_DECREF(args); /* replacing args */
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
830 *p_args = args = subslice;
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
831 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
832 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
833 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
834 Py_XINCREF(myerrno);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
835 self->myerrno = myerrno;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
836
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
837 Py_XINCREF(strerror);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
838 self->strerror = strerror;
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
839
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
840 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
841 Py_XINCREF(winerror);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
842 self->winerror = winerror;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
843 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
844
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
845 /* Steals the reference to args */
77894
1cbab581bf1e Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents: 77476
diff changeset
846 Py_CLEAR(self->args);
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
847 self->args = args;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
848 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
849
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
850 return 0;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
851 }
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
852
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
853 static PyObject *
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
854 OSError_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
855 static int
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
856 OSError_init(PyOSErrorObject *self, PyObject *args, PyObject *kwds);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
857
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
858 static int
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
859 oserror_use_init(PyTypeObject *type)
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
860 {
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
861 /* When __init__ is defined in a OSError subclass, we want any
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
862 extraneous argument to __new__ to be ignored. The only reasonable
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
863 solution, given __new__ takes a variable number of arguments,
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
864 is to defer arg parsing and initialization to __init__.
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
865
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
866 But when __new__ is overriden as well, it should call our __new__
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
867 with the right arguments.
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
868
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
869 (see http://bugs.python.org/issue12555#msg148829 )
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
870 */
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
871 if (type->tp_init != (initproc) OSError_init &&
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
872 type->tp_new == (newfunc) OSError_new) {
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
873 assert((PyObject *) type != PyExc_OSError);
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
874 return 1;
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
875 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
876 return 0;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
877 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
878
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
879 static PyObject *
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
880 OSError_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
881 {
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
882 PyOSErrorObject *self = NULL;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
883 PyObject *myerrno = NULL, *strerror = NULL, *filename = NULL;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
884 #ifdef MS_WINDOWS
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
885 PyObject *winerror = NULL;
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
886 #endif
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
887
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
888 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
889 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
890 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
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 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
893 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
894 #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
895 , &winerror
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
896 #endif
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
897 ))
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
898 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
899
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
900 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
901 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
902 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
903 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
904 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
905 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
906 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
907 }
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
908 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
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 }
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
912
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
913 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
914 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
915 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
916
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
917 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
918 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
919 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
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 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
922 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
923 #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
924 , winerror
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
925 #endif
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
926 ))
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
927 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
928 }
77894
1cbab581bf1e Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents: 77476
diff changeset
929 else {
1cbab581bf1e Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents: 77476
diff changeset
930 self->args = PyTuple_New(0);
1cbab581bf1e Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents: 77476
diff changeset
931 if (self->args == NULL)
1cbab581bf1e Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents: 77476
diff changeset
932 goto error;
1cbab581bf1e Issue #15229: An OSError subclass whose __init__ doesn't call back
Antoine Pitrou <solipsis@pitrou.net>
parents: 77476
diff changeset
933 }
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
934
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
935 return (PyObject *) self;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
936
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
937 error:
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
938 Py_XDECREF(args);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
939 Py_XDECREF(self);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
940 return NULL;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
941 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
942
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
943 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
944 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
945 {
73981
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
946 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
947 #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
948 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
949 #endif
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
950
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
951 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
952 /* 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
953 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
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 (!_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
956 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
957
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
958 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
959 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
960 #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
961 , &winerror
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
962 #endif
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 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
965
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
966 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
967 #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
968 , winerror
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
969 #endif
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
970 ))
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
971 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
972
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
973 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
974
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
975 error:
d22c99e77768 Fix OSError.__init__ and OSError.__new__ so that each of them can be
Antoine Pitrou <solipsis@pitrou.net>
parents: 73655
diff changeset
976 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
977 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
978 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
979
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
980 static int
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
981 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
982 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
983 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
984 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
985 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
986 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
987 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
988 #endif
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
989 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
990 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
991
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
992 static void
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
993 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
994 {
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39610
diff changeset
995 _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
996 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
997 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
998 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
999
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1000 static int
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1001 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
1002 void *arg)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1003 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1004 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
1005 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
1006 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
1007 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1008 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
1009 #endif
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1010 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
1011 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1012
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1013 static PyObject *
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1014 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
1015 {
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1016 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1017 /* 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
1018 if (self->winerror && self->filename)
78791
2e587b9bae35 Issue #15784: Modify OSError.__str__() to better distinguish between
Richard Oudkerk <shibturn@gmail.com>
parents: 78737
diff changeset
1019 return PyUnicode_FromFormat("[WinError %S] %S: %R",
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1020 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
1021 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
1022 self->filename);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1023 if (self->winerror && self->strerror)
78791
2e587b9bae35 Issue #15784: Modify OSError.__str__() to better distinguish between
Richard Oudkerk <shibturn@gmail.com>
parents: 78737
diff changeset
1024 return PyUnicode_FromFormat("[WinError %S] %S",
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1025 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
1026 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
1027 #endif
41882
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
1028 if (self->filename)
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
1029 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
1030 self->myerrno ? self->myerrno: Py_None,
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
1031 self->strerror ? self->strerror: Py_None,
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
1032 self->filename);
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1033 if (self->myerrno && self->strerror)
41882
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
1034 return PyUnicode_FromFormat("[Errno %S] %S",
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
1035 self->myerrno ? self->myerrno: Py_None,
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
1036 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
1037 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
1038 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1039
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1040 static PyObject *
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1041 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
1042 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1043 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
1044 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
1045
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1046 /* 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
1047 * 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
1048 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
1049 args = PyTuple_New(3);
74752
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
1050 if (!args)
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
1051 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
1052
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1053 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
1054 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
1055 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
1056
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1057 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
1058 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
1059 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
1060
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1061 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
1062 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
1063 } else
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1064 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
1065
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1066 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
1067 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
1068 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
1069 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
1070 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
1071 return res;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1072 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1073
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1074 static PyObject *
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1075 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
1076 {
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1077 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
1078 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
1079 return NULL;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1080 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1081 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
1082 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1083
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1084 static int
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1085 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
1086 {
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1087 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
1088 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
1089 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
1090 return -1;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1091 self->written = n;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1092 return 0;
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1093 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1094
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1095 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
1096 {"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
1097 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
1098 {"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
1099 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
1100 {"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
1101 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
1102 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1103 {"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
1104 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
1105 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1106 {NULL} /* Sentinel */
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 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
1110 {"__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
1111 {NULL}
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1112 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1113
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1114 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
1115 {"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
1116 (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
1117 {NULL}
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1118 };
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1119
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1120
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1121 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
1122 OSError, OSError_new,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1123 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
1124 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
1125 "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
1126
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1127
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1128 /*
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1129 * 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
1130 */
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1131 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
1132 "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
1133 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
1134 "Connection error.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1135 MiddlingExtendsException(PyExc_OSError, ChildProcessError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1136 "Child process error.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1137 MiddlingExtendsException(PyExc_ConnectionError, BrokenPipeError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1138 "Broken pipe.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1139 MiddlingExtendsException(PyExc_ConnectionError, ConnectionAbortedError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1140 "Connection aborted.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1141 MiddlingExtendsException(PyExc_ConnectionError, ConnectionRefusedError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1142 "Connection refused.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1143 MiddlingExtendsException(PyExc_ConnectionError, ConnectionResetError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1144 "Connection reset.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1145 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
1146 "File already exists.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1147 MiddlingExtendsException(PyExc_OSError, FileNotFoundError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1148 "File not found.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1149 MiddlingExtendsException(PyExc_OSError, IsADirectoryError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1150 "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
1151 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
1152 "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
1153 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
1154 "Interrupted by signal.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1155 MiddlingExtendsException(PyExc_OSError, PermissionError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1156 "Not enough permissions.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1157 MiddlingExtendsException(PyExc_OSError, ProcessLookupError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1158 "Process not found.");
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1159 MiddlingExtendsException(PyExc_OSError, TimeoutError, OSError,
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
1160 "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
1161
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1162 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1163 * 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
1164 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1165 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
1166 "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
1167
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1168
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1169 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1170 * 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
1171 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1172 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
1173 "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
1174
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1175
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 * 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
1178 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1179 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
1180 "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
1181
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1182 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1183 * 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
1184 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1185 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
1186 "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
1187
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 * 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
1190 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1191 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
1192 "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
1193
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1194 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1195 * 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
1196 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1197 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
1198 "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
1199
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1200
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1201 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1202 * 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
1203 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1204
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1205 static int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1206 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
1207 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1208 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
1209 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
1210
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1211 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
1212 return -1;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1213
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1214 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
1215 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
1216 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
1217 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
1218 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1219 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
1220 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
1221 info = PySequence_Tuple(info);
74752
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
1222 if (!info)
e35f1c431302 put returns on their own lines
Benjamin Peterson <benjamin@python.org>
parents: 74506
diff changeset
1223 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
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 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
1226 /* 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
1227 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
1228 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
1229 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
1230 }
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1231
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1232 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
1233 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
1234 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
1235
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 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
1237 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
1238 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
1239
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1240 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
1241 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
1242 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
1243
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1244 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
1245 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
1246 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
1247
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1248 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
1249 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1250 return 0;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1251 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1252
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1253 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
1254 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
1255 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1256 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
1257 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
1258 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
1259 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
1260 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
1261 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
1262 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
1263 }
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 static void
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1266 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
1267 {
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39610
diff changeset
1268 _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
1269 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
1270 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
1271 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1272
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1273 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
1274 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
1275 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1276 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
1277 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
1278 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
1279 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
1280 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
1281 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
1282 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
1283 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1284
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1285 /* 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
1286 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
1287 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
1288 static PyObject*
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1289 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
1290 {
61058
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1291 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
1292 int kind;
eb2821cc3edf Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents: 72475
diff changeset
1293 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
1294
72703
eb2821cc3edf Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents: 72475
diff changeset
1295 if (PyUnicode_READY(name))
eb2821cc3edf Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents: 72475
diff changeset
1296 return NULL;
eb2821cc3edf Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents: 72475
diff changeset
1297 kind = PyUnicode_KIND(name);
eb2821cc3edf Fix my_basename(): make the string ready
Victor Stinner <victor.stinner@haypocalc.com>
parents: 72475
diff changeset
1298 data = PyUnicode_DATA(name);
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
1299 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
1300 offset = 0;
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1301 for(i=0; i < size; i++) {
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
1302 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
1303 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
1304 }
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
1305 if (offset != 0)
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
1306 return PyUnicode_Substring(name, offset, size);
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
1307 else {
61058
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1308 Py_INCREF(name);
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1309 return name;
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1310 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1311 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1312
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 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1315 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
1316 {
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1317 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
1318 PyObject *filename;
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1319 PyObject *result;
44158
81e0c0e2a8c1 Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents: 44129
diff changeset
1320 /* 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
1321 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
1322 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
1323 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
1324
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1325 /* 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
1326 lineno here */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1327
42855
d5b52d56beba Use unicode and remove support for some uses of str8.
Neal Norwitz <nnorwitz@gmail.com>
parents: 42669
diff changeset
1328 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
1329 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
1330 if (filename == NULL)
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1331 return NULL;
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1332 } else {
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1333 filename = NULL;
42305
d0719406b2c6 Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents: 42118
diff changeset
1334 }
44158
81e0c0e2a8c1 Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents: 44129
diff changeset
1335 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
1336
42305
d0719406b2c6 Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents: 42118
diff changeset
1337 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
1338 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
1339
42305
d0719406b2c6 Change Py_BuildValue to generate Unicode objects for
Martin v. Löwis <martin@v.loewis.de>
parents: 42118
diff changeset
1340 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
1341 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
1342 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
1343 filename,
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 59128
diff changeset
1344 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
1345 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
1346 result = PyUnicode_FromFormat("%S (%U)",
41882
1056530616ac Change tp_str implementations of exception classes
Walter Dörwald <walter@livinglogic.de>
parents: 41782
diff changeset
1347 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
1348 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
1349 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
1350 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
1351 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
1352 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
1353 Py_XDECREF(filename);
04a18e59cc2c Don't decode/recode the unicode filename in SyntaxError_str()
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59127
diff changeset
1354 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
1355 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1356
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1357 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
1358 {"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
1359 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
1360 {"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
1361 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
1362 {"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
1363 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
1364 {"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
1365 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
1366 {"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
1367 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
1368 {"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
1369 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
1370 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
1371 {NULL} /* Sentinel */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1372 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1373
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1374 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
1375 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
1376 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
1377
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1378
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1379 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1380 * 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
1381 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1382 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
1383 "Improper indentation.");
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1384
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1385
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1386 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1387 * 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
1388 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1389 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
1390 "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
1391
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1392
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1393 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1394 * 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
1395 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1396 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
1397 "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
1398
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1399
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1400 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1401 * 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
1402 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1403 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
1404 "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
1405
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1406
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1407 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1408 * 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
1409 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1410 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1411 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
1412 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1413 /* 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
1414 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
1415 KeyError: ''
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1416 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
1417 KeyError
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1418 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
1419 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
1420 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
1421 */
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1422 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
1423 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
1424 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1425 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
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 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
1429 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
1430
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1431
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1432 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1433 * 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
1434 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
1435 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
1436 "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
1437
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1438 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1439 * 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
1440 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1441
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1442 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
1443 "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
1444
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1445 static PyObject *
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1446 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
1447 {
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1448 if (!attr) {
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1449 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
1450 return NULL;
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1451 }
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1452
47301
23ab586c427a Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents: 46682
diff changeset
1453 if (!PyBytes_Check(attr)) {
41611
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1454 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
1455 return NULL;
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1456 }
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1457 Py_INCREF(attr);
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1458 return attr;
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1459 }
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1460
c48fe4dc34a9 Change UnicodeDecodeError objects so that the 'object' attribute
Walter Dörwald <walter@livinglogic.de>
parents: 41587
diff changeset
1461 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
1462 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
1463 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1464 if (!attr) {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1465 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
1466 return NULL;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1467 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1468
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1469 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
1470 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
1471 "%.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
1472 return NULL;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1473 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1474 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
1475 return attr;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1476 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1477
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1478 static int
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1479 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
1480 {
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1481 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
1482 if (!obj)
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1483 return -1;
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1484 Py_CLEAR(*attr);
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1485 *attr = obj;
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1486 return 0;
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1487 }
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1488
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1489 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1490 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
1491 {
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1492 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
1493 }
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 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1496 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
1497 {
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1498 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
1499 }
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 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1502 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
1503 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1504 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
1505 }
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 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1508 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
1509 {
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1510 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
1511 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1512
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1513 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1514 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
1515 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1516 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
1517 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1518
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1519 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1520 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
1521 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1522 Py_ssize_t size;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1523 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
1524 "object");
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1525 if (!obj)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1526 return -1;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1527 *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
1528 size = PyUnicode_GET_LENGTH(obj);
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1529 if (*start<0)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1530 *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
1531 if (*start>=size)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1532 *start = size-1;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1533 Py_DECREF(obj);
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1534 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
1535 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1536
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1537
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1538 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1539 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
1540 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1541 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
1542 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
1543 if (!obj)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1544 return -1;
47301
23ab586c427a Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents: 46682
diff changeset
1545 size = PyBytes_GET_SIZE(obj);
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1546 *start = ((PyUnicodeErrorObject *)exc)->start;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1547 if (*start<0)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1548 *start = 0;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1549 if (*start>=size)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1550 *start = size-1;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1551 Py_DECREF(obj);
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1552 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
1553 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1554
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1555
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1556 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1557 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
1558 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1559 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
1560 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1561
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1562
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1563 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1564 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
1565 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1566 ((PyUnicodeErrorObject *)exc)->start = start;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1567 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
1568 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1569
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1570
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1571 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1572 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
1573 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1574 ((PyUnicodeErrorObject *)exc)->start = start;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1575 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
1576 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1577
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1578
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1579 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1580 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
1581 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1582 ((PyUnicodeErrorObject *)exc)->start = start;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1583 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
1584 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1585
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1586
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1587 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1588 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
1589 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1590 Py_ssize_t size;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1591 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
1592 "object");
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1593 if (!obj)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1594 return -1;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1595 *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
1596 size = PyUnicode_GET_LENGTH(obj);
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1597 if (*end<1)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1598 *end = 1;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1599 if (*end>size)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1600 *end = size;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1601 Py_DECREF(obj);
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1602 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
1603 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1604
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1605
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1606 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1607 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
1608 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1609 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
1610 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
1611 if (!obj)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1612 return -1;
47301
23ab586c427a Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents: 46682
diff changeset
1613 size = PyBytes_GET_SIZE(obj);
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1614 *end = ((PyUnicodeErrorObject *)exc)->end;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1615 if (*end<1)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1616 *end = 1;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1617 if (*end>size)
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1618 *end = size;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1619 Py_DECREF(obj);
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1620 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
1621 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1622
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1623
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1624 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1625 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
1626 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1627 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
1628 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1629
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1630
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1631 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1632 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
1633 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1634 ((PyUnicodeErrorObject *)exc)->end = end;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1635 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
1636 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1637
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1638
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1639 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1640 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
1641 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1642 ((PyUnicodeErrorObject *)exc)->end = end;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1643 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
1644 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1645
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1646
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1647 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1648 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
1649 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1650 ((PyUnicodeErrorObject *)exc)->end = end;
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1651 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
1652 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1653
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1654 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1655 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
1656 {
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1657 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
1658 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1659
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1660
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1661 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1662 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
1663 {
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1664 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
1665 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1666
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1667
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1668 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1669 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
1670 {
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1671 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
1672 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1673
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1674
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1675 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1676 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
1677 {
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1678 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
1679 reason);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1680 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1681
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1682
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1683 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1684 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
1685 {
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1686 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
1687 reason);
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1688 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1689
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 int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1692 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
1693 {
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1694 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
1695 reason);
38453
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
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1698
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1699 static int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1700 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
1701 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1702 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
1703 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
1704 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
1705 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
1706 }
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 static void
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1709 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
1710 {
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39610
diff changeset
1711 _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
1712 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
1713 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
1714 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1715
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1716 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
1717 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
1718 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1719 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
1720 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
1721 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
1722 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
1723 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1724
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1725 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
1726 {"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
1727 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
1728 {"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
1729 PyDoc_STR("exception object")},
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1730 {"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
1731 PyDoc_STR("exception start")},
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1732 {"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
1733 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
1734 {"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
1735 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
1736 {NULL} /* Sentinel */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1737 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1738
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1739
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1740 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1741 * 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
1742 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1743
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1744 static int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1745 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
1746 {
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1747 PyUnicodeErrorObject *err;
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1748
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1749 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
1750 return -1;
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1751
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1752 err = (PyUnicodeErrorObject *)self;
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1753
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1754 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
1755 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
1756 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
1757
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1758 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
1759 &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
1760 &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
1761 &err->start,
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1762 &err->end,
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1763 &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
1764 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
1765 return -1;
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1766 }
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1767
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
1768 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
1769 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
1770 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
1771 }
0883d6a103a0 Port error handlers from Py_UNICODE indexing to code point indexing.
Martin v. Löwis <martin@v.loewis.de>
parents: 72879
diff changeset
1772
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1773 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
1774 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
1775 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
1776
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1777 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
1778 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1779
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1780 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1781 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
1782 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1783 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1784 PyObject *result = NULL;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1785 PyObject *reason_str = NULL;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1786 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
1787
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1788 /* 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
1789 they've been modified after we were contructed. */
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1790 reason_str = PyObject_Str(uself->reason);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1791 if (reason_str == NULL)
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1792 goto done;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1793 encoding_str = PyObject_Str(uself->encoding);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1794 if (encoding_str == NULL)
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1795 goto done;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1796
73644
5b426bf9260c UnicodeEncodeError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents: 73350
diff changeset
1797 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
1798 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
1799 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
1800 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
1801 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
1802 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
1803 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
1804 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
1805 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
1806 result = PyUnicode_FromFormat(
41940
5014f8daa57f PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents: 41882
diff changeset
1807 fmt,
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1808 encoding_str,
73644
5b426bf9260c UnicodeEncodeError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents: 73350
diff changeset
1809 (int)badchar,
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1810 uself->start,
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1811 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
1812 }
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1813 else {
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1814 result = PyUnicode_FromFormat(
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1815 "'%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
1816 encoding_str,
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1817 uself->start,
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1818 uself->end-1,
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1819 reason_str);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1820 }
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1821 done:
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1822 Py_XDECREF(reason_str);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1823 Py_XDECREF(encoding_str);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1824 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
1825 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1826
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1827 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
1828 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
1829 "UnicodeEncodeError",
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1830 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
1831 (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
1832 (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
1833 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
1834 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
1835 (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
1836 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
1837 (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
1838 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1839 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
1840
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1841 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1842 PyUnicodeEncodeError_Create(
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1843 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
1844 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
1845 {
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
1846 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
1847 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
1848 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1849
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1850
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1851 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1852 * 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
1853 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1854
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1855 static int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1856 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
1857 {
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1858 PyUnicodeErrorObject *ude;
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1859 const char *data;
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1860 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
1861
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1862 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
1863 return -1;
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1864
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1865 ude = (PyUnicodeErrorObject *)self;
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1866
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1867 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
1868 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
1869 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
1870
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1871 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
1872 &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
1873 &ude->object,
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1874 &ude->start,
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1875 &ude->end,
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1876 &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
1877 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
1878 return -1;
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
47301
23ab586c427a Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents: 46682
diff changeset
1881 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
1882 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
1883 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
1884 return -1;
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1885 }
47301
23ab586c427a Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents: 46682
diff changeset
1886 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
1887 }
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1888 else {
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1889 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
1890 }
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1891
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1892 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
1893 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
1894
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
1895 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
1896 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1897
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1898 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1899 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
1900 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1901 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1902 PyObject *result = NULL;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1903 PyObject *reason_str = NULL;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1904 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
1905
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1906 /* 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
1907 they've been modified after we were contructed. */
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1908 reason_str = PyObject_Str(uself->reason);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1909 if (reason_str == NULL)
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1910 goto done;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1911 encoding_str = PyObject_Str(uself->encoding);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1912 if (encoding_str == NULL)
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1913 goto done;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1914
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1915 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
1916 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
1917 result = PyUnicode_FromFormat(
41940
5014f8daa57f PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents: 41882
diff changeset
1918 "'%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
1919 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
1920 byte,
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1921 uself->start,
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1922 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
1923 }
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1924 else {
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1925 result = PyUnicode_FromFormat(
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1926 "'%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
1927 encoding_str,
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1928 uself->start,
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1929 uself->end-1,
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1930 reason_str
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1931 );
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1932 }
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1933 done:
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1934 Py_XDECREF(reason_str);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1935 Py_XDECREF(encoding_str);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1936 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
1937 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1938
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1939 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
1940 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
1941 "UnicodeDecodeError",
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1942 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
1943 (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
1944 (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
1945 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
1946 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
1947 (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
1948 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
1949 (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
1950 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1951 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
1952
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1953 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1954 PyUnicodeDecodeError_Create(
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1955 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
1956 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
1957 {
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
1958 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
1959 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
1960 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1961
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1962
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1963 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1964 * 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
1965 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1966
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1967 static int
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1968 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
1969 PyObject *kwds)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1970 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1971 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
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
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1974 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
1975 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
1976
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1977 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
1978 &PyUnicode_Type, &self->object,
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1979 &self->start,
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1980 &self->end,
41766
d6aa7edf217a Add 'U'/'U#' format characters to Py_BuildValue (and thus
Walter Dörwald <walter@livinglogic.de>
parents: 41749
diff changeset
1981 &PyUnicode_Type, &self->reason)) {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1982 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
1983 return -1;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1984 }
38669
19fd6141940d Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
1985
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1986 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
1987 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
1988
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1989 return 0;
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1990 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1991
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1992
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1993 static PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1994 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
1995 {
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
1996 PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1997 PyObject *result = NULL;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
1998 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
1999
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2000 /* 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
2001 modified after we were contructed. */
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2002 reason_str = PyObject_Str(uself->reason);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2003 if (reason_str == NULL)
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2004 goto done;
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2005
73649
244d9159aa38 UnicodeTranslateError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents: 73644
diff changeset
2006 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
2007 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
2008 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
2009 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
2010 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
2011 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
2012 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
2013 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
2014 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
2015 result = PyUnicode_FromFormat(
41940
5014f8daa57f PyUnicode_FromFormat() does support %02x, so use it
Walter Dörwald <walter@livinglogic.de>
parents: 41882
diff changeset
2016 fmt,
73649
244d9159aa38 UnicodeTranslateError uses the new Unicode API
Victor Stinner <victor.stinner@haypocalc.com>
parents: 73644
diff changeset
2017 (int)badchar,
42110
e4f649c4f457 Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
2018 uself->start,
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2019 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
2020 );
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2021 } else {
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2022 result = PyUnicode_FromFormat(
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2023 "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
2024 uself->start,
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2025 uself->end-1,
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2026 reason_str
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2027 );
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2028 }
59111
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2029 done:
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2030 Py_XDECREF(reason_str);
c8ef906b11b8 Merged revisions 78420 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 54770
diff changeset
2031 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
2032 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2033
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2034 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
2035 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
2036 "UnicodeTranslateError",
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2037 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
2038 (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
2039 (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
2040 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
2041 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
2042 (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
2043 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
2044 (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
2045 };
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2046 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
2047
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2048 /* Deprecated. */
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2049 PyObject *
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2050 PyUnicodeTranslateError_Create(
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2051 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
2052 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
2053 {
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2054 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
2055 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
2056 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2057
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2058 PyObject *
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2059 _PyUnicodeTranslateError_Create(
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2060 PyObject *object,
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2061 Py_ssize_t start, Py_ssize_t end, const char *reason)
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2062 {
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2063 return PyObject_CallFunction(PyExc_UnicodeTranslateError, "Ons",
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2064 object, start, end, reason);
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 70403
diff changeset
2065 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2066
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2067 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2068 * 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
2069 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2070 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
2071 "Assertion failed.");
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
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2074 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2075 * 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
2076 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2077 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
2078 "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
2079
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2080
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2081 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2082 * 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
2083 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2084 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
2085 "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
2086
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2087
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2088 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2089 * 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
2090 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2091 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
2092 "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
2093
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2094
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2095 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2096 * 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
2097 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2098 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
2099 "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
2100
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2101
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2102 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2103 * 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
2104 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2105 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
2106 "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
2107 "\n"
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2108 "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
2109 "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
2110
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2111
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2112 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2113 * 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
2114 */
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2115 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
2116 "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
2117
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2118
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2119 /*
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41940
diff changeset
2120 * 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
2121 */
65690
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2122
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2123 #define MEMERRORS_SAVE 16
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2124 static PyBaseExceptionObject *memerrors_freelist = NULL;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2125 static int memerrors_numfree = 0;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2126
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2127 static PyObject *
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2128 MemoryError_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2129 {
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2130 PyBaseExceptionObject *self;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2131
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2132 if (type != (PyTypeObject *) PyExc_MemoryError)
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2133 return BaseException_new(type, args, kwds);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2134 if (memerrors_freelist == NULL)
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2135 return BaseException_new(type, args, kwds);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2136 /* Fetch object from freelist and revive it */
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2137 self = memerrors_freelist;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2138 self->args = PyTuple_New(0);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2139 /* 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
2140 if (self->args == NULL)
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2141 return NULL;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2142 memerrors_freelist = (PyBaseExceptionObject *) self->dict;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2143 memerrors_numfree--;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2144 self->dict = NULL;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2145 _Py_NewReference((PyObject *)self);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2146 _PyObject_GC_TRACK(self);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2147 return (PyObject *)self;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2148 }
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2149
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2150 static void
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2151 MemoryError_dealloc(PyBaseExceptionObject *self)
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 _PyObject_GC_UNTRACK(self);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2154 BaseException_clear(self);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2155 if (memerrors_numfree >= MEMERRORS_SAVE)
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2156 Py_TYPE(self)->tp_free((PyObject *)self);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2157 else {
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2158 self->dict = (PyObject *) memerrors_freelist;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2159 memerrors_freelist = self;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2160 memerrors_numfree++;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2161 }
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2162 }
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2163
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2164 static void
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2165 preallocate_memerrors(void)
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2166 {
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2167 /* 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
2168 up the freelist. */
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2169 int i;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2170 PyObject *errors[MEMERRORS_SAVE];
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2171 for (i = 0; i < MEMERRORS_SAVE; i++) {
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2172 errors[i] = MemoryError_new((PyTypeObject *) PyExc_MemoryError,
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2173 NULL, NULL);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2174 if (!errors[i])
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2175 Py_FatalError("Could not preallocate MemoryError object");
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2176 }
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2177 for (i = 0; i < MEMERRORS_SAVE; i++) {
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2178 Py_DECREF(errors[i]);
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 void
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2183 free_preallocated_memerrors(void)
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2184 {
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2185 while (memerrors_freelist != NULL) {
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2186 PyObject *self = (PyObject *) memerrors_freelist;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2187 memerrors_freelist = (PyBaseExceptionObject *) memerrors_freelist->dict;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2188 Py_TYPE(self)->tp_free((PyObject *)self);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2189 }
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2190 }
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2191
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2192
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2193 static PyTypeObject _PyExc_MemoryError = {
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2194 PyVarObject_HEAD_INIT(NULL, 0)
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2195 "MemoryError",
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2196 sizeof(PyBaseExceptionObject),
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2197 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
2198 0, 0, 0, 0, 0, 0, 0,
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2199 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
2200 PyDoc_STR("Out of memory."), (traverseproc)BaseException_traverse,
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2201 (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
2202 0, 0, 0, offsetof(PyBaseExceptionObject, dict),
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2203 (initproc)BaseException_init, 0, MemoryError_new
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2204 };
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2205 PyObject *PyExc_MemoryError = (PyObject *) &_PyExc_MemoryError;
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2206
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2207
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
2208 /*
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
2209 * 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
2210 */
85c22b4d4455 Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118.
Travis E. Oliphant <oliphant@enthought.com>
parents: 42334
diff changeset
2211 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
2212
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2213
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2214 /* 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
2215
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2216 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2217 * 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
2218 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2219 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
2220 "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
2221
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2222
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2223 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2224 * 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
2225 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2226 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
2227 "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
2228
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2229
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2230 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2231 * 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
2232 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2233 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
2234 "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
2235
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 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2238 * 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
2239 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2240 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
2241 "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
2242 "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
2243
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2244
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2245 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2246 * 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
2247 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2248 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
2249 "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
2250
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2251
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2252 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2253 * 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
2254 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2255 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
2256 "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
2257
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 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2260 * 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
2261 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2262 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
2263 "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
2264 "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
2265
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2266
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2267 /*
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2268 * 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
2269 */
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2270 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
2271 "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
2272
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2273
39610
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
2274 /*
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
2275 * 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
2276 */
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
2277 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
2278 "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
2279 "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
2280
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
2281
43777
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
2282 /*
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
2283 * BytesWarning extends Warning
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
2284 */
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
2285 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
2286 "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
2287 "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
2288
0d462d789b18 Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents: 43696
diff changeset
2289
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
2290 /*
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
2291 * 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
2292 */
39b9e9de372b Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents: 62443
diff changeset
2293 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
2294 "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
2295
39b9e9de372b Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
Georg Brandl <georg@python.org>
parents: 62443
diff changeset
2296
39610
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 39442
diff changeset
2297
43292
876b7ef4775d Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 43188
diff changeset
2298 /* 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
2299 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
2300 depth will cause its own infinite recursion.
876b7ef4775d Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 43188
diff changeset
2301 */
876b7ef4775d Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 43188
diff changeset
2302 PyObject *PyExc_RecursionErrorInst = NULL;
876b7ef4775d Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 43188
diff changeset
2303
74506
5ffa409af22e Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents: 74498
diff changeset
2304 #define PRE_INIT(TYPE) \
5ffa409af22e Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents: 74498
diff changeset
2305 if (!(_PyExc_ ## TYPE.tp_flags & Py_TPFLAGS_READY)) { \
5ffa409af22e Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents: 74498
diff changeset
2306 if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \
5ffa409af22e Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents: 74498
diff changeset
2307 Py_FatalError("exceptions bootstrapping error."); \
5ffa409af22e Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents: 74498
diff changeset
2308 Py_INCREF(PyExc_ ## TYPE); \
5ffa409af22e Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents: 74498
diff changeset
2309 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2310
74506
5ffa409af22e Fix refleaks in test_capi
Antoine Pitrou <solipsis@pitrou.net>
parents: 74498
diff changeset
2311 #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
2312 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
2313 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
2314
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2315 #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
2316 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
2317 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
2318 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
2319 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
2320
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2321 #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
2322 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
2323 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
2324 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
2325 Py_FatalError("errmap insertion problem."); \
74508
29a28018e567 Fix some of the remaining test_capi refleaks
Antoine Pitrou <solipsis@pitrou.net>
parents: 74507
diff changeset
2326 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
2327 }
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2328
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2329 #ifdef MS_WINDOWS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2330 #include <Winsock2.h>
76898
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2331 /* The following constants were added to errno.h in VS2010 but have
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2332 preferred WSA equivalents. */
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2333 #undef EADDRINUSE
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2334 #undef EADDRNOTAVAIL
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2335 #undef EAFNOSUPPORT
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2336 #undef EALREADY
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2337 #undef ECONNABORTED
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2338 #undef ECONNREFUSED
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2339 #undef ECONNRESET
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2340 #undef EDESTADDRREQ
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2341 #undef EHOSTUNREACH
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2342 #undef EINPROGRESS
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2343 #undef EISCONN
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2344 #undef ELOOP
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2345 #undef EMSGSIZE
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2346 #undef ENETDOWN
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2347 #undef ENETRESET
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2348 #undef ENETUNREACH
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2349 #undef ENOBUFS
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2350 #undef ENOPROTOOPT
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2351 #undef ENOTCONN
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2352 #undef ENOTSOCK
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2353 #undef EOPNOTSUPP
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2354 #undef EPROTONOSUPPORT
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2355 #undef EPROTOTYPE
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2356 #undef ETIMEDOUT
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2357 #undef EWOULDBLOCK
38d7d944370e Fix #13210. Port the Windows build from VS2008 to VS2010.
Brian Curtin <brian@python.org>
parents: 76303
diff changeset
2358
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2359 #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
2360 #define EALREADY WSAEALREADY
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2361 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2362 #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
2363 #define ECONNABORTED WSAECONNABORTED
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2364 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2365 #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
2366 #define ECONNREFUSED WSAECONNREFUSED
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2367 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2368 #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
2369 #define ECONNRESET WSAECONNRESET
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2370 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2371 #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
2372 #define EINPROGRESS WSAEINPROGRESS
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2373 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2374 #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
2375 #define ESHUTDOWN WSAESHUTDOWN
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2376 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2377 #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
2378 #define ETIMEDOUT WSAETIMEDOUT
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2379 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2380 #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
2381 #define EWOULDBLOCK WSAEWOULDBLOCK
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2382 #endif
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2383 #endif /* MS_WINDOWS */
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 38673
diff changeset
2384
47580
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 47301
diff changeset
2385 void
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 76272
diff changeset
2386 _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
2387 {
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 76272
diff changeset
2388 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
2389
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(BaseException)
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(Exception)
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(TypeError)
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(StopIteration)
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(GeneratorExit)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2395 PRE_INIT(SystemExit)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2396 PRE_INIT(KeyboardInterrupt)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2397 PRE_INIT(ImportError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2398 PRE_INIT(OSError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2399 PRE_INIT(EOFError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2400 PRE_INIT(RuntimeError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2401 PRE_INIT(NotImplementedError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2402 PRE_INIT(NameError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2403 PRE_INIT(UnboundLocalError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2404 PRE_INIT(AttributeError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2405 PRE_INIT(SyntaxError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2406 PRE_INIT(IndentationError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2407 PRE_INIT(TabError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2408 PRE_INIT(LookupError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2409 PRE_INIT(IndexError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2410 PRE_INIT(KeyError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2411 PRE_INIT(ValueError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2412 PRE_INIT(UnicodeError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2413 PRE_INIT(UnicodeEncodeError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2414 PRE_INIT(UnicodeDecodeError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2415 PRE_INIT(UnicodeTranslateError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2416 PRE_INIT(AssertionError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2417 PRE_INIT(ArithmeticError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2418 PRE_INIT(FloatingPointError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2419 PRE_INIT(OverflowError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2420 PRE_INIT(ZeroDivisionError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2421 PRE_INIT(SystemError)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2422 PRE_INIT(ReferenceError)
42669
2c51be9904de Code review of the new buffer protocol. Mostly add questions that should
Neal Norwitz <nnorwitz@gmail.com>
parents: 42665
diff changeset
2423 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
2424 PRE_INIT(MemoryError)
48437
fa34088380f9 #3295 actually define PyExc_BufferError
Benjamin Peterson <benjamin@python.org>
parents: 47580
diff changeset
2425 PRE_INIT(BufferError)
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2426 PRE_INIT(Warning)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2427 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
2428 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
2429 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
2430 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
2431 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
2432 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
2433 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
2434 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
2435 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
2436 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
2437
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2438 /* OSError subclasses */
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2439 PRE_INIT(ConnectionError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2440
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2441 PRE_INIT(BlockingIOError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2442 PRE_INIT(BrokenPipeError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2443 PRE_INIT(ChildProcessError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2444 PRE_INIT(ConnectionAbortedError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2445 PRE_INIT(ConnectionRefusedError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2446 PRE_INIT(ConnectionResetError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2447 PRE_INIT(FileExistsError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2448 PRE_INIT(FileNotFoundError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2449 PRE_INIT(IsADirectoryError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2450 PRE_INIT(NotADirectoryError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2451 PRE_INIT(InterruptedError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2452 PRE_INIT(PermissionError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2453 PRE_INIT(ProcessLookupError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2454 PRE_INIT(TimeoutError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2455
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2456 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
2457 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
2458 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
2459
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(BaseException)
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(Exception)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2462 POST_INIT(TypeError)
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(StopIteration)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2464 POST_INIT(GeneratorExit)
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(SystemExit)
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(KeyboardInterrupt)
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(ImportError)
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(OSError)
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2469 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
2470 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
2471 #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
2472 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
2473 #endif
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2474 #ifdef __VMS
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2475 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
2476 #endif
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2477 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
2478 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
2479 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
2480 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
2481 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
2482 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
2483 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
2484 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
2485 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
2486 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
2487 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
2488 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
2489 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
2490 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
2491 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
2492 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
2493 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
2494 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
2495 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
2496 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
2497 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
2498 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
2499 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
2500 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
2501 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
2502 POST_INIT(MemoryError)
48437
fa34088380f9 #3295 actually define PyExc_BufferError
Benjamin Peterson <benjamin@python.org>
parents: 47580
diff changeset
2503 POST_INIT(BufferError)
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2504 POST_INIT(Warning)
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2505 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
2506 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
2507 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
2508 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
2509 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
2510 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
2511 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
2512 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
2513 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
2514 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
2515
74509
44d8aa3c1003 Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents: 74508
diff changeset
2516 if (!errnomap) {
44d8aa3c1003 Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents: 74508
diff changeset
2517 errnomap = PyDict_New();
44d8aa3c1003 Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents: 74508
diff changeset
2518 if (!errnomap)
44d8aa3c1003 Fix some of the remaining test_capi leaks
Antoine Pitrou <solipsis@pitrou.net>
parents: 74508
diff changeset
2519 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
2520 }
72879
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2521
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2522 /* OSError subclasses */
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2523 POST_INIT(ConnectionError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2524
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2525 POST_INIT(BlockingIOError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2526 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
2527 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
2528 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
2529 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
2530 POST_INIT(BrokenPipeError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2531 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
2532 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
2533 POST_INIT(ChildProcessError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2534 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
2535 POST_INIT(ConnectionAbortedError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2536 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
2537 POST_INIT(ConnectionRefusedError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2538 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
2539 POST_INIT(ConnectionResetError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2540 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
2541 POST_INIT(FileExistsError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2542 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
2543 POST_INIT(FileNotFoundError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2544 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
2545 POST_INIT(IsADirectoryError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2546 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
2547 POST_INIT(NotADirectoryError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2548 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
2549 POST_INIT(InterruptedError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2550 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
2551 POST_INIT(PermissionError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2552 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
2553 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
2554 POST_INIT(ProcessLookupError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2555 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
2556 POST_INIT(TimeoutError);
41a1de81ef2b PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72703
diff changeset
2557 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
2558
65690
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2559 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
2560
74498
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2561 if (!PyExc_RecursionErrorInst) {
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2562 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
2563 if (!PyExc_RecursionErrorInst)
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2564 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
2565 "recursion errors");
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2566 else {
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2567 PyBaseExceptionObject *err_inst =
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2568 (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2569 PyObject *args_tuple;
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2570 PyObject *exc_message;
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2571 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
2572 if (!exc_message)
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2573 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
2574 "pre-allocation");
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2575 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
2576 if (!args_tuple)
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2577 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
2578 "pre-allocation");
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2579 Py_DECREF(exc_message);
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2580 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
2581 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
2582 Py_DECREF(args_tuple);
ab5b47bf6711 Fix leaking a RuntimeError objects when creating sub-interpreters
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
2583 }
43292
876b7ef4775d Merged revisions 57778-58052 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 43188
diff changeset
2584 }
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2585 }
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2586
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2587 void
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2588 _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
2589 {
65690
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2590 Py_CLEAR(PyExc_RecursionErrorInst);
c6d86439aa91 Merged revisions 85896 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 62448
diff changeset
2591 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
2592 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
2593 }