Mercurial > cpython-lru_cache-weakref
annotate Objects/structseq.c @ 39496:352ffe77b71d legacy-trunk
Patch #1535500: fix segfault in BZ2File.writelines and make sure it
raises the correct exceptions.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Mon, 14 Aug 2006 21:42:55 +0000 |
| parents | e11caad7e029 |
| children | 6620a510e9a9 |
| rev | line source |
|---|---|
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /* Implementation helper: a struct that looks like a tuple. See timemodule |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 and posixmodule for example uses. */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 #include "Python.h" |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 #include "structmember.h" |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 #include "structseq.h" |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 static char visible_length_key[] = "n_sequence_fields"; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 static char real_length_key[] = "n_fields"; |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
10 static char unnamed_fields_key[] = "n_unnamed_fields"; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
12 /* Fields with this name have only a field index, not a field name. |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
13 They are only allowed for indices < n_visible_fields. */ |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
14 char *PyStructSequence_UnnamedField = "unnamed field"; |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
15 |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 #define VISIBLE_SIZE(op) ((op)->ob_size) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 #define VISIBLE_SIZE_TP(tp) PyInt_AsLong( \ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 PyDict_GetItemString((tp)->tp_dict, visible_length_key)) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 #define REAL_SIZE_TP(tp) PyInt_AsLong( \ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 PyDict_GetItemString((tp)->tp_dict, real_length_key)) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 #define REAL_SIZE(op) REAL_SIZE_TP((op)->ob_type) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
24 #define UNNAMED_FIELDS_TP(tp) PyInt_AsLong( \ |
|
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
25 PyDict_GetItemString((tp)->tp_dict, unnamed_fields_key)) |
|
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
26 #define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP((op)->ob_type) |
|
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
27 |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 PyStructSequence_New(PyTypeObject *type) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 PyStructSequence *obj; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
22978
363c7fc174ac
Remove PyMalloc_New and PyMalloc_Del.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
22446
diff
changeset
|
34 obj = PyObject_New(PyStructSequence, type); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 obj->ob_size = VISIBLE_SIZE_TP(type); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 return (PyObject*) obj; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 static void |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 structseq_dealloc(PyStructSequence *obj) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 { |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
43 Py_ssize_t i, size; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 size = REAL_SIZE(obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 for (i = 0; i < size; ++i) { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 Py_XDECREF(obj->ob_item[i]); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 } |
|
22978
363c7fc174ac
Remove PyMalloc_New and PyMalloc_Del.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
22446
diff
changeset
|
49 PyObject_Del(obj); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
52 static Py_ssize_t |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 structseq_length(PyStructSequence *obj) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 return VISIBLE_SIZE(obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 static PyObject* |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
59 structseq_item(PyStructSequence *obj, Py_ssize_t i) |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 if (i < 0 || i >= VISIBLE_SIZE(obj)) { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 PyErr_SetString(PyExc_IndexError, "tuple index out of range"); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 return NULL; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 Py_INCREF(obj->ob_item[i]); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 return obj->ob_item[i]; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 static PyObject* |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
70 structseq_slice(PyStructSequence *obj, Py_ssize_t low, Py_ssize_t high) |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 PyTupleObject *np; |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
73 Py_ssize_t i; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 if (low < 0) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 low = 0; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 if (high > VISIBLE_SIZE(obj)) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 high = VISIBLE_SIZE(obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 if (high < low) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 high = low; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 np = (PyTupleObject *)PyTuple_New(high-low); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 if (np == NULL) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 return NULL; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 for(i = low; i < high; ++i) { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 PyObject *v = obj->ob_item[i]; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 Py_INCREF(v); |
|
20780
ab2e315849a7
Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
20540
diff
changeset
|
87 PyTuple_SET_ITEM(np, i-low, v); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 return (PyObject *) np; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 PyObject *arg = NULL; |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
96 PyObject *dict = NULL; |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
97 PyObject *ob; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 PyStructSequence *res = NULL; |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
99 Py_ssize_t len, min_len, max_len, i, n_unnamed_fields; |
|
36675
dba6494735d0
Revert backwards-incompatible const changes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36519
diff
changeset
|
100 static char *kwlist[] = {"sequence", "dict", 0}; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
102 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq", |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
103 kwlist, &arg, &dict)) |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 return NULL; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
106 arg = PySequence_Fast(arg, "constructor requires a sequence"); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
107 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
108 if (!arg) { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
109 return NULL; |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
110 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
111 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
112 if (dict && !PyDict_Check(dict)) { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
113 PyErr_Format(PyExc_TypeError, |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
114 "%.500s() takes a dict as second arg, if any", |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
115 type->tp_name); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
116 Py_DECREF(arg); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 return NULL; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
120 len = PySequence_Fast_GET_SIZE(arg); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
121 min_len = VISIBLE_SIZE_TP(type); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
122 max_len = REAL_SIZE_TP(type); |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
123 n_unnamed_fields = UNNAMED_FIELDS_TP(type); |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
124 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
125 if (min_len != max_len) { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
126 if (len < min_len) { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
127 PyErr_Format(PyExc_TypeError, |
|
36510
0f3894bb2ada
Support %zd in PyErr_Format and PyString_FromFormat.
Martin v. Löwis <martin@v.loewis.de>
parents:
36509
diff
changeset
|
128 "%.500s() takes an at least %zd-sequence (%zd-sequence given)", |
| 36511 | 129 type->tp_name, min_len, len); |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
130 Py_DECREF(arg); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
131 return NULL; |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
132 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
133 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
134 if (len > max_len) { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
135 PyErr_Format(PyExc_TypeError, |
|
36510
0f3894bb2ada
Support %zd in PyErr_Format and PyString_FromFormat.
Martin v. Löwis <martin@v.loewis.de>
parents:
36509
diff
changeset
|
136 "%.500s() takes an at most %zd-sequence (%zd-sequence given)", |
| 36511 | 137 type->tp_name, max_len, len); |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
138 Py_DECREF(arg); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
139 return NULL; |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
140 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
141 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
142 else { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
143 if (len != min_len) { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
144 PyErr_Format(PyExc_TypeError, |
|
36510
0f3894bb2ada
Support %zd in PyErr_Format and PyString_FromFormat.
Martin v. Löwis <martin@v.loewis.de>
parents:
36509
diff
changeset
|
145 "%.500s() takes a %zd-sequence (%zd-sequence given)", |
| 36511 | 146 type->tp_name, min_len, len); |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
147 Py_DECREF(arg); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
148 return NULL; |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
149 } |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 res = (PyStructSequence*) PyStructSequence_New(type); |
|
26708
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
153 if (res == NULL) { |
|
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
154 return NULL; |
|
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
155 } |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 for (i = 0; i < len; ++i) { |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
157 PyObject *v = PySequence_Fast_GET_ITEM(arg, i); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
158 Py_INCREF(v); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
159 res->ob_item[i] = v; |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
160 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
161 for (; i < max_len; ++i) { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
162 if (dict && (ob = PyDict_GetItemString( |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
163 dict, type->tp_members[i-n_unnamed_fields].name))) { |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
164 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
165 else { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
166 ob = Py_None; |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
167 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
168 Py_INCREF(ob); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
169 res->ob_item[i] = ob; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
172 Py_DECREF(arg); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 return (PyObject*) res; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 make_tuple(PyStructSequence *obj) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 return structseq_slice(obj, 0, VISIBLE_SIZE(obj)); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 structseq_repr(PyStructSequence *obj) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
185 PyObject *tup, *str; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
186 tup = make_tuple(obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 str = PyObject_Repr(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 return str; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
190 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 structseq_concat(PyStructSequence *obj, PyObject *b) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 PyObject *tup, *result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 tup = make_tuple(obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 result = PySequence_Concat(tup, b); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 static PyObject * |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
203 structseq_repeat(PyStructSequence *obj, Py_ssize_t n) |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 PyObject *tup, *result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 tup = make_tuple(obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 result = PySequence_Repeat(tup, n); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 static int |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 structseq_contains(PyStructSequence *obj, PyObject *o) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 PyObject *tup; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 int result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 tup = make_tuple(obj); |
|
39445
e11caad7e029
Klocwork made another run and found a bunch more problems.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37745
diff
changeset
|
218 if (!tup) |
|
e11caad7e029
Klocwork made another run and found a bunch more problems.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37745
diff
changeset
|
219 return -1; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 result = PySequence_Contains(tup, o); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
223 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 static long |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 structseq_hash(PyObject *obj) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
228 PyObject *tup; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 long result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 tup = make_tuple((PyStructSequence*) obj); |
|
39445
e11caad7e029
Klocwork made another run and found a bunch more problems.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37745
diff
changeset
|
231 if (!tup) |
|
e11caad7e029
Klocwork made another run and found a bunch more problems.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37745
diff
changeset
|
232 return -1; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
233 result = PyObject_Hash(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 structseq_richcompare(PyObject *obj, PyObject *o2, int op) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
240 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 PyObject *tup, *result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
242 tup = make_tuple((PyStructSequence*) obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
243 result = PyObject_RichCompare(tup, o2, op); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
244 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
245 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
248 static PyObject * |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
249 structseq_reduce(PyStructSequence* self) |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
250 { |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
251 PyObject* tup; |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
252 PyObject* dict; |
|
22168
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
253 PyObject* result; |
|
36519
d6d415df0df0
Use Py_ssize_t for counts and sizes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36511
diff
changeset
|
254 Py_ssize_t n_fields, n_visible_fields, n_unnamed_fields; |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
255 int i; |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
256 |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
257 n_fields = REAL_SIZE(self); |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
258 n_visible_fields = VISIBLE_SIZE(self); |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
259 n_unnamed_fields = UNNAMED_FIELDS(self); |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
260 tup = PyTuple_New(n_visible_fields); |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
261 if (!tup) { |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
262 return NULL; |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
263 } |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
264 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
265 dict = PyDict_New(); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
266 if (!dict) { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
267 Py_DECREF(tup); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
268 return NULL; |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
269 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
270 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
271 for (i = 0; i < n_visible_fields; i++) { |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
272 Py_INCREF(self->ob_item[i]); |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
273 PyTuple_SET_ITEM(tup, i, self->ob_item[i]); |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
274 } |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
275 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
276 for (; i < n_fields; i++) { |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
277 char *n = self->ob_type->tp_members[i-n_unnamed_fields].name; |
|
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
278 PyDict_SetItemString(dict, n, |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
279 self->ob_item[i]); |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
280 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
281 |
|
22168
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
282 result = Py_BuildValue("(O(OO))", self->ob_type, tup, dict); |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
283 |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
284 Py_DECREF(tup); |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
285 Py_DECREF(dict); |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
286 |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
287 return result; |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
288 } |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
289 |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
290 static PySequenceMethods structseq_as_sequence = { |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
291 (lenfunc)structseq_length, |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
292 (binaryfunc)structseq_concat, /* sq_concat */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
293 (ssizeargfunc)structseq_repeat, /* sq_repeat */ |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
294 (ssizeargfunc)structseq_item, /* sq_item */ |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
295 (ssizessizeargfunc)structseq_slice, /* sq_slice */ |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
296 0, /* sq_ass_item */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
297 0, /* sq_ass_slice */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
298 (objobjproc)structseq_contains, /* sq_contains */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
299 }; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
301 static PyMethodDef structseq_methods[] = { |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
302 {"__reduce__", (PyCFunction)structseq_reduce, |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
303 METH_NOARGS, NULL}, |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
304 {NULL, NULL} |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
305 }; |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
306 |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
307 static PyTypeObject _struct_sequence_template = { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
308 PyObject_HEAD_INIT(&PyType_Type) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 0, /* ob_size */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 NULL, /* tp_name */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 0, /* tp_basicsize */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 0, /* tp_itemsize */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 (destructor)structseq_dealloc, /* tp_dealloc */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 0, /* tp_print */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 0, /* tp_getattr */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 0, /* tp_setattr */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 0, /* tp_compare */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 (reprfunc)structseq_repr, /* tp_repr */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 0, /* tp_as_number */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 &structseq_as_sequence, /* tp_as_sequence */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 0, /* tp_as_mapping */ |
|
37304
79a0f080f898
Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents:
36675
diff
changeset
|
322 structseq_hash, /* tp_hash */ |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
323 0, /* tp_call */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 0, /* tp_str */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 0, /* tp_getattro */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
326 0, /* tp_setattro */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 0, /* tp_as_buffer */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 Py_TPFLAGS_DEFAULT, /* tp_flags */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 NULL, /* tp_doc */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
330 0, /* tp_traverse */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 0, /* tp_clear */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 structseq_richcompare, /* tp_richcompare */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 0, /* tp_weaklistoffset */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 0, /* tp_iter */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 0, /* tp_iternext */ |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
336 structseq_methods, /* tp_methods */ |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
337 NULL, /* tp_members */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
338 0, /* tp_getset */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
339 0, /* tp_base */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
340 0, /* tp_dict */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
341 0, /* tp_descr_get */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
342 0, /* tp_descr_set */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
343 0, /* tp_dictoffset */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
344 0, /* tp_init */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
345 0, /* tp_alloc */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 structseq_new, /* tp_new */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
347 }; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
348 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
349 void |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
350 PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
351 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
352 PyObject *dict; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
353 PyMemberDef* members; |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
354 int n_members, n_unnamed_members, i, k; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
355 |
|
37745
353fe06dab5b
Unlink the structseq type from the global list of
Martin v. Löwis <martin@v.loewis.de>
parents:
37304
diff
changeset
|
356 #ifdef Py_TRACE_REFS |
|
353fe06dab5b
Unlink the structseq type from the global list of
Martin v. Löwis <martin@v.loewis.de>
parents:
37304
diff
changeset
|
357 /* if the type object was chained, unchain it first |
|
353fe06dab5b
Unlink the structseq type from the global list of
Martin v. Löwis <martin@v.loewis.de>
parents:
37304
diff
changeset
|
358 before overwriting its storage */ |
|
353fe06dab5b
Unlink the structseq type from the global list of
Martin v. Löwis <martin@v.loewis.de>
parents:
37304
diff
changeset
|
359 if (type->_ob_next) { |
|
353fe06dab5b
Unlink the structseq type from the global list of
Martin v. Löwis <martin@v.loewis.de>
parents:
37304
diff
changeset
|
360 _Py_ForgetReference((PyObject*)type); |
|
353fe06dab5b
Unlink the structseq type from the global list of
Martin v. Löwis <martin@v.loewis.de>
parents:
37304
diff
changeset
|
361 } |
|
353fe06dab5b
Unlink the structseq type from the global list of
Martin v. Löwis <martin@v.loewis.de>
parents:
37304
diff
changeset
|
362 #endif |
|
353fe06dab5b
Unlink the structseq type from the global list of
Martin v. Löwis <martin@v.loewis.de>
parents:
37304
diff
changeset
|
363 |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
364 n_unnamed_members = 0; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
365 for (i = 0; desc->fields[i].name != NULL; ++i) |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
366 if (desc->fields[i].name == PyStructSequence_UnnamedField) |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
367 n_unnamed_members++; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
368 n_members = i; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
370 memcpy(type, &_struct_sequence_template, sizeof(PyTypeObject)); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 type->tp_name = desc->name; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
372 type->tp_doc = desc->doc; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
373 type->tp_basicsize = sizeof(PyStructSequence)+ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
374 sizeof(PyObject*)*(n_members-1); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 type->tp_itemsize = 0; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
376 |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
377 members = PyMem_NEW(PyMemberDef, n_members-n_unnamed_members+1); |
|
26708
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
378 if (members == NULL) |
|
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
379 return; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
380 |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
381 for (i = k = 0; i < n_members; ++i) { |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
382 if (desc->fields[i].name == PyStructSequence_UnnamedField) |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
383 continue; |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
384 members[k].name = desc->fields[i].name; |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
385 members[k].type = T_OBJECT; |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
386 members[k].offset = offsetof(PyStructSequence, ob_item) |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
387 + i * sizeof(PyObject*); |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
388 members[k].flags = READONLY; |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
389 members[k].doc = desc->fields[i].doc; |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
390 k++; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
391 } |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
392 members[k].name = NULL; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
393 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
394 type->tp_members = members; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
395 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
396 if (PyType_Ready(type) < 0) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
397 return; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
398 Py_INCREF(type); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
399 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
400 dict = type->tp_dict; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
401 PyDict_SetItemString(dict, visible_length_key, |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
402 PyInt_FromLong((long) desc->n_in_sequence)); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
403 PyDict_SetItemString(dict, real_length_key, |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
404 PyInt_FromLong((long) n_members)); |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
405 PyDict_SetItemString(dict, unnamed_fields_key, |
|
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
406 PyInt_FromLong((long) n_unnamed_members)); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
407 } |
