Mercurial > cpython-lru_cache-weakref
annotate Objects/structseq.c @ 46567:ffeecbebf3ca
Block 2.6-only doc change.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sat, 26 Apr 2008 18:28:08 +0000 |
| parents | 1154158a199f |
| children | 85b67fb5672b |
| 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 |
|
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:
44099
diff
changeset
|
16 #define VISIBLE_SIZE(op) Py_SIZE(op) |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43100
diff
changeset
|
17 #define VISIBLE_SIZE_TP(tp) PyLong_AsLong( \ |
|
20540
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 |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43100
diff
changeset
|
20 #define REAL_SIZE_TP(tp) PyLong_AsLong( \ |
|
20540
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)) |
|
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:
44099
diff
changeset
|
22 #define REAL_SIZE(op) REAL_SIZE_TP(Py_TYPE(op)) |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43100
diff
changeset
|
24 #define UNNAMED_FIELDS_TP(tp) PyLong_AsLong( \ |
|
25808
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)) |
|
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:
44099
diff
changeset
|
26 #define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP(Py_TYPE(op)) |
|
25808
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; |
|
44674
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
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); |
|
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:
44099
diff
changeset
|
35 Py_SIZE(obj) = VISIBLE_SIZE_TP(type); |
|
20540
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 * |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
93 structseq_subscript(PyStructSequence *self, PyObject *item) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
94 { |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
95 if (PyIndex_Check(item)) { |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
96 Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
97 if (i == -1 && PyErr_Occurred()) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
98 return NULL; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
99 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
100 if (i < 0) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
101 i += VISIBLE_SIZE(self); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
102 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
103 if (i < 0 || i >= VISIBLE_SIZE(self)) { |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
104 PyErr_SetString(PyExc_IndexError, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
105 "tuple index out of range"); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
106 return NULL; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
107 } |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
108 Py_INCREF(self->ob_item[i]); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
109 return self->ob_item[i]; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
110 } |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
111 else if (PySlice_Check(item)) { |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
112 Py_ssize_t start, stop, step, slicelen, cur, i; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
113 PyObject *result; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
114 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
115 if (PySlice_GetIndicesEx((PySliceObject *)item, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
116 VISIBLE_SIZE(self), &start, &stop, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
117 &step, &slicelen) < 0) { |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
118 return NULL; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
119 } |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
120 if (slicelen <= 0) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
121 return PyTuple_New(0); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
122 result = PyTuple_New(slicelen); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
123 if (result == NULL) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
124 return NULL; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
125 for (cur = start, i = 0; i < slicelen; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
126 cur += step, i++) { |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
127 PyObject *v = self->ob_item[cur]; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
128 Py_INCREF(v); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
129 PyTuple_SET_ITEM(result, i, v); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
130 } |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
131 return result; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
132 } |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
133 else { |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
134 PyErr_SetString(PyExc_TypeError, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
135 "structseq index must be integer"); |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
136 return NULL; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
137 } |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
138 } |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
139 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
140 static PyObject * |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 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
|
142 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 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
|
144 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
|
145 PyObject *ob; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 PyStructSequence *res = NULL; |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
147 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
|
148 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
|
149 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
150 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
|
151 kwlist, &arg, &dict)) |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 return NULL; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
153 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
154 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
|
155 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
156 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
|
157 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
|
158 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
159 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
160 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
|
161 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
|
162 "%.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
|
163 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
|
164 Py_DECREF(arg); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 return NULL; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
166 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
168 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
|
169 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
|
170 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
|
171 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
|
172 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 "%.500s() takes an at least %zd-sequence (%zd-sequence given)", |
| 36511 | 177 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
|
178 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
|
179 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
|
180 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
181 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
182 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
|
183 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
|
184 "%.500s() takes an at most %zd-sequence (%zd-sequence given)", |
| 36511 | 185 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
|
186 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
|
187 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
|
188 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
189 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
190 else { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
191 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
|
192 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
|
193 "%.500s() takes a %zd-sequence (%zd-sequence given)", |
| 36511 | 194 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
|
195 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
|
196 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
|
197 } |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 res = (PyStructSequence*) PyStructSequence_New(type); |
|
26708
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
201 if (res == NULL) { |
|
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
202 return NULL; |
|
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
203 } |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 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
|
208 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
213 else { |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
214 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
|
215 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
216 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
|
217 res->ob_item[i] = ob; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
220 Py_DECREF(arg); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 return (PyObject*) res; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 } |
|
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 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 make_tuple(PyStructSequence *obj) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 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
|
228 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 structseq_repr(PyStructSequence *obj) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 { |
|
44674
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
233 /* buffer and type size were chosen well considered. */ |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
234 #define REPR_BUFFER_SIZE 512 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
235 #define TYPE_MAXSIZE 100 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
236 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
237 PyObject *tup; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
238 PyTypeObject *typ = Py_TYPE(obj); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
239 int i, removelast = 0; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
240 Py_ssize_t len; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
241 char buf[REPR_BUFFER_SIZE]; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
242 char *endofbuf, *pbuf = buf; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
243 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
244 /* pointer to end of writeable buffer; safes space for "...)\0" */ |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
245 endofbuf= &buf[REPR_BUFFER_SIZE-5]; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
246 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
247 if ((tup = make_tuple(obj)) == NULL) { |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
248 return NULL; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
249 } |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
250 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
251 /* "typename(", limited to TYPE_MAXSIZE */ |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
252 len = strlen(typ->tp_name) > TYPE_MAXSIZE ? TYPE_MAXSIZE : |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
253 strlen(typ->tp_name); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
254 strncpy(pbuf, typ->tp_name, len); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
255 pbuf += len; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
256 *pbuf++ = '('; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
257 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
258 for (i=0; i < VISIBLE_SIZE(obj); i++) { |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
259 PyObject *val, *repr; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
260 char *cname, *crepr; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
261 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
262 cname = typ->tp_members[i].name; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
263 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
264 val = PyTuple_GetItem(tup, i); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
265 if (cname == NULL || val == NULL) { |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
266 return NULL; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
267 } |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
268 repr = PyObject_Repr(val); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
269 if (repr == NULL) { |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
270 Py_DECREF(tup); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
271 return NULL; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
272 } |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
273 crepr = PyUnicode_AsString(repr); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
274 if (crepr == NULL) { |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
275 Py_DECREF(tup); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
276 Py_DECREF(repr); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
277 return NULL; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
278 } |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
279 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
280 /* + 3: keep space for "=" and ", " */ |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
281 len = strlen(cname) + strlen(crepr) + 3; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
282 if ((pbuf+len) <= endofbuf) { |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
283 strcpy(pbuf, cname); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
284 pbuf += strlen(cname); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
285 *pbuf++ = '='; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
286 strcpy(pbuf, crepr); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
287 pbuf += strlen(crepr); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
288 *pbuf++ = ','; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
289 *pbuf++ = ' '; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
290 removelast = 1; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
291 Py_DECREF(repr); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
292 } |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
293 else { |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
294 strcpy(pbuf, "..."); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
295 pbuf += 3; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
296 removelast = 0; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
297 Py_DECREF(repr); |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
298 break; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
299 } |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
300 } |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
301 Py_DECREF(tup); |
|
44674
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
302 if (removelast) { |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
303 /* overwrite last ", " */ |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
304 pbuf-=2; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
305 } |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
306 *pbuf++ = ')'; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
307 *pbuf = '\0'; |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
308 |
|
1154158a199f
Merged revisions 59933-59951 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44351
diff
changeset
|
309 return PyUnicode_FromString(buf); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 structseq_concat(PyStructSequence *obj, PyObject *b) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 PyObject *tup, *result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 tup = make_tuple(obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 result = PySequence_Concat(tup, b); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
322 static PyObject * |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
323 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
|
324 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 PyObject *tup, *result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
326 tup = make_tuple(obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 result = PySequence_Repeat(tup, n); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
330 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 static int |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 structseq_contains(PyStructSequence *obj, PyObject *o) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 PyObject *tup; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
336 int result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
337 tup = make_tuple(obj); |
|
39610
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
338 if (!tup) |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
339 return -1; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
340 result = PySequence_Contains(tup, o); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
341 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
342 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
343 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
344 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
345 static long |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 structseq_hash(PyObject *obj) |
|
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 PyObject *tup; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
349 long result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
350 tup = make_tuple((PyStructSequence*) obj); |
|
39610
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
351 if (!tup) |
|
3674f20ac781
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
352 return -1; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
353 result = PyObject_Hash(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
354 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
355 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
356 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
357 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
358 static PyObject * |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
359 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
|
360 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
361 PyObject *tup, *result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
362 tup = make_tuple((PyStructSequence*) obj); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
363 result = PyObject_RichCompare(tup, o2, op); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
364 Py_DECREF(tup); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
365 return result; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
366 } |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
367 |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
368 static PyObject * |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
369 structseq_reduce(PyStructSequence* self) |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
370 { |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
371 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
|
372 PyObject* dict; |
|
22168
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
373 PyObject* result; |
|
36519
d6d415df0df0
Use Py_ssize_t for counts and sizes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36511
diff
changeset
|
374 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
|
375 int i; |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
376 |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
377 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
|
378 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
|
379 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
|
380 tup = PyTuple_New(n_visible_fields); |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
381 if (!tup) { |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
382 return NULL; |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
383 } |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
384 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
385 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
|
386 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
|
387 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
|
388 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
|
389 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
390 |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
391 for (i = 0; i < n_visible_fields; i++) { |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
392 Py_INCREF(self->ob_item[i]); |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
393 PyTuple_SET_ITEM(tup, i, self->ob_item[i]); |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
394 } |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
395 |
|
22166
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
396 for (; i < n_fields; i++) { |
|
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:
44099
diff
changeset
|
397 char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name; |
|
25808
fdca87c4234e
Add n_unnamed_fields into the type.
Martin v. Löwis <martin@v.loewis.de>
parents:
25806
diff
changeset
|
398 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
|
399 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
|
400 } |
|
837951ecdce9
After some thinking, I decided to move all of this across onto
Michael W. Hudson <mwh@python.net>
parents:
22137
diff
changeset
|
401 |
|
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:
44099
diff
changeset
|
402 result = Py_BuildValue("(O(OO))", Py_TYPE(self), tup, dict); |
|
22168
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
403 |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
404 Py_DECREF(tup); |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
405 Py_DECREF(dict); |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
406 |
|
68831ac5495b
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
22166
diff
changeset
|
407 return result; |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
408 } |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
409 |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
410 static PySequenceMethods structseq_as_sequence = { |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
411 (lenfunc)structseq_length, |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
412 (binaryfunc)structseq_concat, /* sq_concat */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
413 (ssizeargfunc)structseq_repeat, /* sq_repeat */ |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35999
diff
changeset
|
414 (ssizeargfunc)structseq_item, /* sq_item */ |
|
43100
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
415 0, /* sq_slice */ |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 0, /* sq_ass_item */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
417 0, /* sq_ass_slice */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
418 (objobjproc)structseq_contains, /* sq_contains */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
419 }; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
420 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
421 static PyMappingMethods structseq_as_mapping = { |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
422 (lenfunc)structseq_length, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
423 (binaryfunc)structseq_subscript, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
424 }; |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
425 |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
426 static PyMethodDef structseq_methods[] = { |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
427 {"__reduce__", (PyCFunction)structseq_reduce, |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
428 METH_NOARGS, NULL}, |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
429 {NULL, NULL} |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
430 }; |
|
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
431 |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
432 static PyTypeObject _struct_sequence_template = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
39610
diff
changeset
|
433 PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
434 NULL, /* tp_name */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
435 0, /* tp_basicsize */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
436 0, /* tp_itemsize */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
437 (destructor)structseq_dealloc, /* tp_dealloc */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
438 0, /* tp_print */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
439 0, /* tp_getattr */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
440 0, /* tp_setattr */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
441 0, /* tp_compare */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
442 (reprfunc)structseq_repr, /* tp_repr */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
443 0, /* tp_as_number */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
444 &structseq_as_sequence, /* tp_as_sequence */ |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
445 &structseq_as_mapping, /* tp_as_mapping */ |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36675
diff
changeset
|
446 structseq_hash, /* tp_hash */ |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
447 0, /* tp_call */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
448 0, /* tp_str */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
449 0, /* tp_getattro */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
450 0, /* tp_setattro */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
451 0, /* tp_as_buffer */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
452 Py_TPFLAGS_DEFAULT, /* tp_flags */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
453 NULL, /* tp_doc */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
454 0, /* tp_traverse */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
455 0, /* tp_clear */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
456 structseq_richcompare, /* tp_richcompare */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
457 0, /* tp_weaklistoffset */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
458 0, /* tp_iter */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
459 0, /* tp_iternext */ |
|
22137
1a5110b4bd72
backport my checkin of
Michael W. Hudson <mwh@python.net>
parents:
21081
diff
changeset
|
460 structseq_methods, /* tp_methods */ |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
461 NULL, /* tp_members */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
462 0, /* tp_getset */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
463 0, /* tp_base */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
464 0, /* tp_dict */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
465 0, /* tp_descr_get */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
466 0, /* tp_descr_set */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
467 0, /* tp_dictoffset */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
468 0, /* tp_init */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
469 0, /* tp_alloc */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
470 structseq_new, /* tp_new */ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
471 }; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
472 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
473 void |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
474 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
|
475 { |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
476 PyObject *dict; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
477 PyMemberDef* members; |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
478 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
|
479 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36675
diff
changeset
|
480 #ifdef Py_TRACE_REFS |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36675
diff
changeset
|
481 /* if the type object was chained, unchain it first |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36675
diff
changeset
|
482 before overwriting its storage */ |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
39610
diff
changeset
|
483 if (type->ob_base.ob_base._ob_next) { |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36675
diff
changeset
|
484 _Py_ForgetReference((PyObject*)type); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36675
diff
changeset
|
485 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36675
diff
changeset
|
486 #endif |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36675
diff
changeset
|
487 |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
488 n_unnamed_members = 0; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
489 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
|
490 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
|
491 n_unnamed_members++; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
492 n_members = i; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
493 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
494 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
|
495 type->tp_name = desc->name; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
496 type->tp_doc = desc->doc; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
497 type->tp_basicsize = sizeof(PyStructSequence)+ |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
498 sizeof(PyObject*)*(n_members-1); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
499 type->tp_itemsize = 0; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
500 |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
501 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
|
502 if (members == NULL) |
|
3593f2b91d7d
SF # 654974, fix unchecked return values in structseq
Neal Norwitz <nnorwitz@gmail.com>
parents:
25808
diff
changeset
|
503 return; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
504 |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
505 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
|
506 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
|
507 continue; |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
508 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
|
509 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
|
510 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
|
511 + i * sizeof(PyObject*); |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
512 members[k].flags = READONLY; |
|
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
513 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
|
514 k++; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
515 } |
|
25806
0bbea4dcd9be
Add PyStructSequence_UnnamedField. Add stat_float_times.
Martin v. Löwis <martin@v.loewis.de>
parents:
22978
diff
changeset
|
516 members[k].name = NULL; |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
517 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
518 type->tp_members = members; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
519 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
520 if (PyType_Ready(type) < 0) |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
521 return; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
522 Py_INCREF(type); |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
523 |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
524 dict = type->tp_dict; |
|
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
525 PyDict_SetItemString(dict, visible_length_key, |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43100
diff
changeset
|
526 PyLong_FromLong((long) desc->n_in_sequence)); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
527 PyDict_SetItemString(dict, real_length_key, |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43100
diff
changeset
|
528 PyLong_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
|
529 PyDict_SetItemString(dict, unnamed_fields_key, |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43100
diff
changeset
|
530 PyLong_FromLong((long) n_unnamed_members)); |
|
20540
ad2662095d77
Missing file structseq.c for SF patch #462296
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
531 } |
