Mercurial > cpython-lru_cache-weakref
annotate Objects/sliceobject.c @ 73323:dad02a080bbc
Improve byte-compilation in packaging to be independent of -O or -B.
The code I fixed to comply with PEP 3147 still had one bug: When run
under python -O, some paths for pyc files would be pyo, because I called
imp.cache_from_source without explicit debug_override argument in some
places, and under -O that would return .pyo (this is well explained in
the imp docs). Now all code (util.byte_compile, build_py, install_lib)
can create .pyo files according to options given by users,
without interference from the calling Python’s own optimize mode.
On a related topic, I also removed the code that prevented byte
compilation under python -B. The rationale is that packaging gives
control over the creation of pyc files to the user with its own explicit
option, and the behavior should not be changed if the calling Python
happens to run with -B for whatever reason. I will argue that this is a
bug fix and ask to be allowed to backport this change to distutils.
Finally, I moved one nugget of information about the --compile and
--optimize options from the source into the doc. It clears up a
misunderstanding that I (and maybe other people) had.
| author | Éric Araujo <merwok@netwok.org> |
|---|---|
| date | Thu, 03 Nov 2011 05:08:28 +0100 |
| parents | 7bf70519795c |
| children | fa2f8dd077e0 |
| rev | line source |
|---|---|
| 3837 | 1 /* |
| 2 Written by Jim Hugunin and Chris Chase. | |
| 3 | |
|
4403
3b3f7c3f6da2
Ellipses -> Ellipsis rename (the dictionary really says that it should
Guido van Rossum <guido@python.org>
parents:
3861
diff
changeset
|
4 This includes both the singular ellipsis object and slice objects. |
| 3837 | 5 |
| 6 Guido, feel free to do whatever you want in the way of copyrights | |
| 7 for this file. | |
| 8 */ | |
| 9 | |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
10 /* |
|
4403
3b3f7c3f6da2
Ellipses -> Ellipsis rename (the dictionary really says that it should
Guido van Rossum <guido@python.org>
parents:
3861
diff
changeset
|
11 Py_Ellipsis encodes the '...' rubber index token. It is similar to |
| 3837 | 12 the Py_NoneStruct in that there is no way to create other objects of |
| 13 this type and there is exactly one in existence. | |
| 14 */ | |
| 15 | |
| 16 #include "Python.h" | |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17080
diff
changeset
|
17 #include "structmember.h" |
| 3837 | 18 |
| 19 static PyObject * | |
|
71614
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
20 ellipsis_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
21 { |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
22 if (PyTuple_GET_SIZE(args) || (kwargs && PyDict_Size(kwargs))) { |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
23 PyErr_SetString(PyExc_TypeError, "EllipsisType takes no arguments"); |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
24 return NULL; |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
25 } |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
26 Py_INCREF(Py_Ellipsis); |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
27 return Py_Ellipsis; |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
28 } |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
29 |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
30 static PyObject * |
|
13458
7908ec855665
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
31 ellipsis_repr(PyObject *op) |
| 3837 | 32 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
33 return PyUnicode_FromString("Ellipsis"); |
| 3837 | 34 } |
| 35 | |
|
53368
b5e2bcbbfa74
Merged revisions 71757 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51271
diff
changeset
|
36 PyTypeObject PyEllipsis_Type = { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
37 PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
38 "ellipsis", /* tp_name */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
39 0, /* tp_basicsize */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
40 0, /* tp_itemsize */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
41 0, /*never called*/ /* tp_dealloc */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
42 0, /* tp_print */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
43 0, /* tp_getattr */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
44 0, /* tp_setattr */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
45 0, /* tp_reserved */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
46 ellipsis_repr, /* tp_repr */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
47 0, /* tp_as_number */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
48 0, /* tp_as_sequence */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
49 0, /* tp_as_mapping */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
50 0, /* tp_hash */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
51 0, /* tp_call */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
52 0, /* tp_str */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
53 PyObject_GenericGetAttr, /* tp_getattro */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
54 0, /* tp_setattro */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
55 0, /* tp_as_buffer */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
56 Py_TPFLAGS_DEFAULT, /* tp_flags */ |
|
71614
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
57 0, /* tp_doc */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
58 0, /* tp_traverse */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
59 0, /* tp_clear */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
60 0, /* tp_richcompare */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
61 0, /* tp_weaklistoffset */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
62 0, /* tp_iter */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
63 0, /* tp_iternext */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
64 0, /* tp_methods */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
65 0, /* tp_members */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
66 0, /* tp_getset */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
67 0, /* tp_base */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
68 0, /* tp_dict */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
69 0, /* tp_descr_get */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
70 0, /* tp_descr_set */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
71 0, /* tp_dictoffset */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
72 0, /* tp_init */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
73 0, /* tp_alloc */ |
|
84c3be27b4c7
make the types of None and Ellipsis callable
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
74 ellipsis_new, /* tp_new */ |
| 3837 | 75 }; |
| 76 | |
|
4403
3b3f7c3f6da2
Ellipses -> Ellipsis rename (the dictionary really says that it should
Guido van Rossum <guido@python.org>
parents:
3861
diff
changeset
|
77 PyObject _Py_EllipsisObject = { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
78 _PyObject_EXTRA_INIT |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
79 1, &PyEllipsis_Type |
| 3837 | 80 }; |
| 81 | |
| 82 | |
| 83 /* Slice object implementation | |
| 84 | |
| 85 start, stop, and step are python objects with None indicating no | |
| 86 index is present. | |
| 87 */ | |
| 88 | |
| 89 PyObject * | |
|
13458
7908ec855665
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
90 PySlice_New(PyObject *start, PyObject *stop, PyObject *step) |
| 3837 | 91 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
92 PySliceObject *obj = PyObject_New(PySliceObject, &PySlice_Type); |
| 3837 | 93 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
94 if (obj == NULL) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
95 return NULL; |
|
15563
35e8a29e5488
Test for NULL returned from PyObject_NEW().
Guido van Rossum <guido@python.org>
parents:
13458
diff
changeset
|
96 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
97 if (step == NULL) step = Py_None; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
98 Py_INCREF(step); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
99 if (start == NULL) start = Py_None; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
100 Py_INCREF(start); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
101 if (stop == NULL) stop = Py_None; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
102 Py_INCREF(stop); |
| 3837 | 103 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
104 obj->step = step; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
105 obj->start = start; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
106 obj->stop = stop; |
| 3837 | 107 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
108 return (PyObject *) obj; |
| 3837 | 109 } |
| 110 | |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
111 PyObject * |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
112 _PySlice_FromIndices(Py_ssize_t istart, Py_ssize_t istop) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
113 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
114 PyObject *start, *end, *slice; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
115 start = PyLong_FromSsize_t(istart); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
116 if (!start) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
117 return NULL; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
118 end = PyLong_FromSsize_t(istop); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
119 if (!end) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
120 Py_DECREF(start); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
121 return NULL; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
122 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
123 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
124 slice = PySlice_New(start, end, NULL); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
125 Py_DECREF(start); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
126 Py_DECREF(end); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
127 return slice; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
128 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
129 |
| 3837 | 130 int |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65491
diff
changeset
|
131 PySlice_GetIndices(PyObject *_r, Py_ssize_t length, |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35450
diff
changeset
|
132 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) |
| 3837 | 133 { |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65491
diff
changeset
|
134 PySliceObject *r = (PySliceObject*)_r; |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
135 /* XXX support long ints */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
136 if (r->step == Py_None) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
137 *step = 1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
138 } else { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
139 if (!PyLong_Check(r->step)) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
140 *step = PyLong_AsSsize_t(r->step); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
141 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
142 if (r->start == Py_None) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
143 *start = *step < 0 ? length-1 : 0; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
144 } else { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
145 if (!PyLong_Check(r->start)) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
146 *start = PyLong_AsSsize_t(r->start); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
147 if (*start < 0) *start += length; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
148 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
149 if (r->stop == Py_None) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
150 *stop = *step < 0 ? -1 : length; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
151 } else { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
152 if (!PyLong_Check(r->stop)) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
153 *stop = PyLong_AsSsize_t(r->stop); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
154 if (*stop < 0) *stop += length; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
155 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
156 if (*stop > length) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
157 if (*start >= length) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
158 if (*step == 0) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
159 return 0; |
| 3837 | 160 } |
| 161 | |
|
23778
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
162 int |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65491
diff
changeset
|
163 PySlice_GetIndicesEx(PyObject *_r, Py_ssize_t length, |
|
63775
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
164 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, |
|
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
165 Py_ssize_t *slicelength) |
|
23778
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
166 { |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65491
diff
changeset
|
167 PySliceObject *r = (PySliceObject*)_r; |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
168 /* this is harder to get right than you might think */ |
|
26035
6ed2e23aae45
Some days, I think my comment of
Michael W. Hudson <mwh@python.net>
parents:
25228
diff
changeset
|
169 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
170 Py_ssize_t defstart, defstop; |
|
23778
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
171 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
172 if (r->step == Py_None) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
173 *step = 1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
174 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
175 else { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
176 if (!_PyEval_SliceIndex(r->step, step)) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
177 if (*step == 0) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
178 PyErr_SetString(PyExc_ValueError, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
179 "slice step cannot be zero"); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
180 return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
181 } |
|
63775
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
182 /* Here *step might be -PY_SSIZE_T_MAX-1; in this case we replace it |
|
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
183 * with -PY_SSIZE_T_MAX. This doesn't affect the semantics, and it |
|
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
184 * guards against later undefined behaviour resulting from code that |
|
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
185 * does "step = -step" as part of a slice reversal. |
|
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
186 */ |
|
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
187 if (*step < -PY_SSIZE_T_MAX) |
|
f7bd28b3c683
In PySlice_IndicesEx, clip the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX] rather than [PY_SSIZE_T_MIN, PY_SSIZE_T_MAX].
Mark Dickinson <dickinsm@gmail.com>
parents:
61466
diff
changeset
|
188 *step = -PY_SSIZE_T_MAX; |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
189 } |
|
23778
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
190 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
191 defstart = *step < 0 ? length-1 : 0; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
192 defstop = *step < 0 ? -1 : length; |
|
23778
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
193 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
194 if (r->start == Py_None) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
195 *start = defstart; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
196 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
197 else { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
198 if (!_PyEval_SliceIndex(r->start, start)) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
199 if (*start < 0) *start += length; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
200 if (*start < 0) *start = (*step < 0) ? -1 : 0; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
201 if (*start >= length) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
202 *start = (*step < 0) ? length - 1 : length; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
203 } |
|
23778
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
204 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
205 if (r->stop == Py_None) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
206 *stop = defstop; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
207 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
208 else { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
209 if (!_PyEval_SliceIndex(r->stop, stop)) return -1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
210 if (*stop < 0) *stop += length; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
211 if (*stop < 0) *stop = (*step < 0) ? -1 : 0; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
212 if (*stop >= length) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
213 *stop = (*step < 0) ? length - 1 : length; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
214 } |
|
26035
6ed2e23aae45
Some days, I think my comment of
Michael W. Hudson <mwh@python.net>
parents:
25228
diff
changeset
|
215 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
216 if ((*step < 0 && *stop >= *start) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
217 || (*step > 0 && *start >= *stop)) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
218 *slicelength = 0; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
219 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
220 else if (*step < 0) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
221 *slicelength = (*stop-*start+1)/(*step)+1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
222 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
223 else { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
224 *slicelength = (*stop-*start-1)/(*step)+1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
225 } |
|
23778
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
226 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
227 return 0; |
|
23778
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
228 } |
|
245224d1b8c9
This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents:
22978
diff
changeset
|
229 |
|
23868
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
230 static PyObject * |
|
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
231 slice_new(PyTypeObject *type, PyObject *args, PyObject *kw) |
|
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
232 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
233 PyObject *start, *stop, *step; |
|
23868
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
234 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
235 start = stop = step = NULL; |
|
23868
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
236 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
237 if (!_PyArg_NoKeywords("slice()", kw)) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
238 return NULL; |
|
35450
97c97194e64b
Disallow keyword arguments for type constructors that don't use them
Georg Brandl <georg@python.org>
parents:
30332
diff
changeset
|
239 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
240 if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step)) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
241 return NULL; |
|
23868
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
242 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
243 /* This swapping of stop and start is to maintain similarity with |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
244 range(). */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
245 if (stop == NULL) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
246 stop = start; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
247 start = NULL; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
248 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
249 return PySlice_New(start, stop, step); |
|
23868
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
250 } |
|
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
251 |
|
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
252 PyDoc_STRVAR(slice_doc, |
|
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
253 "slice([start,] stop[, step])\n\ |
|
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
254 \n\ |
|
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
255 Create a slice object. This is used for extended slicing (e.g. a[0:10:2])."); |
|
8e6760bf1884
SF patch 568629 by Oren Tirosh: types made callable.
Guido van Rossum <guido@python.org>
parents:
23780
diff
changeset
|
256 |
| 3837 | 257 static void |
|
13458
7908ec855665
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
258 slice_dealloc(PySliceObject *r) |
| 3837 | 259 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
260 Py_DECREF(r->step); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
261 Py_DECREF(r->start); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
262 Py_DECREF(r->stop); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
263 PyObject_Del(r); |
| 3837 | 264 } |
| 265 | |
| 266 static PyObject * | |
|
13458
7908ec855665
ANSI-fication of the sources.
Fred Drake <fdrake@acm.org>
parents:
12576
diff
changeset
|
267 slice_repr(PySliceObject *r) |
| 3837 | 268 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
269 return PyUnicode_FromFormat("slice(%R, %R, %R)", r->start, r->stop, r->step); |
| 3837 | 270 } |
| 271 | |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
272 static PyMemberDef slice_members[] = { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
273 {"start", T_OBJECT, offsetof(PySliceObject, start), READONLY}, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
274 {"stop", T_OBJECT, offsetof(PySliceObject, stop), READONLY}, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
275 {"step", T_OBJECT, offsetof(PySliceObject, step), READONLY}, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
276 {0} |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17080
diff
changeset
|
277 }; |
| 3837 | 278 |
|
24319
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
279 static PyObject* |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
280 slice_indices(PySliceObject* self, PyObject* len) |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
281 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
282 Py_ssize_t ilen, start, stop, step, slicelength; |
|
24319
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
283 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
284 ilen = PyNumber_AsSsize_t(len, PyExc_OverflowError); |
|
24319
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
285 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
286 if (ilen == -1 && PyErr_Occurred()) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
287 return NULL; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
288 } |
|
24319
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
289 |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65491
diff
changeset
|
290 if (PySlice_GetIndicesEx((PyObject*)self, ilen, &start, &stop, |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
291 &step, &slicelength) < 0) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
292 return NULL; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
293 } |
|
24319
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
294 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
295 return Py_BuildValue("(nnn)", start, stop, step); |
|
24319
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
296 } |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
297 |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
298 PyDoc_STRVAR(slice_indices_doc, |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
299 "S.indices(len) -> (start, stop, stride)\n\ |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
300 \n\ |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
301 Assuming a sequence of length len, calculate the start and stop\n\ |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
302 indices, and the stride length of the extended slice described by\n\ |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
303 S. Out of bounds indices are clipped in a manner consistent with the\n\ |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
304 handling of normal slices."); |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
305 |
|
41554
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39644
diff
changeset
|
306 static PyObject * |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39644
diff
changeset
|
307 slice_reduce(PySliceObject* self) |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39644
diff
changeset
|
308 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
309 return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step); |
|
41554
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39644
diff
changeset
|
310 } |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39644
diff
changeset
|
311 |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39644
diff
changeset
|
312 PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39644
diff
changeset
|
313 |
|
24319
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
314 static PyMethodDef slice_methods[] = { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
315 {"indices", (PyCFunction)slice_indices, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
316 METH_O, slice_indices_doc}, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
317 {"__reduce__", (PyCFunction)slice_reduce, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
318 METH_NOARGS, reduce_doc}, |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
319 {NULL, NULL} |
|
24319
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
320 }; |
|
c43466f7dae8
A few days ago, Guido said (in the thread "[Python-Dev] Python
Michael W. Hudson <mwh@python.net>
parents:
23868
diff
changeset
|
321 |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39610
diff
changeset
|
322 static PyObject * |
|
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39610
diff
changeset
|
323 slice_richcompare(PyObject *v, PyObject *w, int op) |
|
17080
52cb0c5fdf23
SF patch #408326 by Robin Thomas: slice objects comparable, not
Guido van Rossum <guido@python.org>
parents:
15563
diff
changeset
|
324 { |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
325 PyObject *t1; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
326 PyObject *t2; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
327 PyObject *res; |
|
17080
52cb0c5fdf23
SF patch #408326 by Robin Thomas: slice objects comparable, not
Guido van Rossum <guido@python.org>
parents:
15563
diff
changeset
|
328 |
|
71810
d0b0fcbb40db
Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
Brian Curtin <brian@python.org>
parents:
71614
diff
changeset
|
329 if (!PySlice_Check(v) || !PySlice_Check(w)) |
|
d0b0fcbb40db
Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
Brian Curtin <brian@python.org>
parents:
71614
diff
changeset
|
330 Py_RETURN_NOTIMPLEMENTED; |
|
42955
30511068d3d4
Fix buglet in sliceobjects, they were not returning Py_NotImplemented when
Thomas Wouters <thomas@python.org>
parents:
42334
diff
changeset
|
331 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
332 if (v == w) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
333 /* XXX Do we really need this shortcut? |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
334 There's a unit test for it, but is that fair? */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
335 switch (op) { |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
336 case Py_EQ: |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
337 case Py_LE: |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
338 case Py_GE: |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
339 res = Py_True; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
340 break; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
341 default: |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
342 res = Py_False; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
343 break; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
344 } |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
345 Py_INCREF(res); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
346 return res; |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
347 } |
|
17080
52cb0c5fdf23
SF patch #408326 by Robin Thomas: slice objects comparable, not
Guido van Rossum <guido@python.org>
parents:
15563
diff
changeset
|
348 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
349 t1 = PyTuple_New(3); |
|
72957
53c87a0275ab
plug possible refleak (closes #13199)
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
350 if (t1 == NULL) |
|
53c87a0275ab
plug possible refleak (closes #13199)
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
351 return NULL; |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
352 t2 = PyTuple_New(3); |
|
72957
53c87a0275ab
plug possible refleak (closes #13199)
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
353 if (t2 == NULL) { |
|
53c87a0275ab
plug possible refleak (closes #13199)
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
354 Py_DECREF(t1); |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
355 return NULL; |
|
72957
53c87a0275ab
plug possible refleak (closes #13199)
Benjamin Peterson <benjamin@python.org>
parents:
66664
diff
changeset
|
356 } |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39610
diff
changeset
|
357 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
358 PyTuple_SET_ITEM(t1, 0, ((PySliceObject *)v)->start); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
359 PyTuple_SET_ITEM(t1, 1, ((PySliceObject *)v)->stop); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
360 PyTuple_SET_ITEM(t1, 2, ((PySliceObject *)v)->step); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
361 PyTuple_SET_ITEM(t2, 0, ((PySliceObject *)w)->start); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
362 PyTuple_SET_ITEM(t2, 1, ((PySliceObject *)w)->stop); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
363 PyTuple_SET_ITEM(t2, 2, ((PySliceObject *)w)->step); |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39610
diff
changeset
|
364 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
365 res = PyObject_RichCompare(t1, t2, op); |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39610
diff
changeset
|
366 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
367 PyTuple_SET_ITEM(t1, 0, NULL); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
368 PyTuple_SET_ITEM(t1, 1, NULL); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
369 PyTuple_SET_ITEM(t1, 2, NULL); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
370 PyTuple_SET_ITEM(t2, 0, NULL); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
371 PyTuple_SET_ITEM(t2, 1, NULL); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
372 PyTuple_SET_ITEM(t2, 2, NULL); |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39610
diff
changeset
|
373 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
374 Py_DECREF(t1); |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
375 Py_DECREF(t2); |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39610
diff
changeset
|
376 |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
377 return res; |
|
17080
52cb0c5fdf23
SF patch #408326 by Robin Thomas: slice objects comparable, not
Guido van Rossum <guido@python.org>
parents:
15563
diff
changeset
|
378 } |
| 3837 | 379 |
| 380 PyTypeObject PySlice_Type = { | |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
381 PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
382 "slice", /* Name of this type */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
383 sizeof(PySliceObject), /* Basic object size */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
384 0, /* Item size for varobject */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
385 (destructor)slice_dealloc, /* tp_dealloc */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
386 0, /* tp_print */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
387 0, /* tp_getattr */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
388 0, /* tp_setattr */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
389 0, /* tp_reserved */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
390 (reprfunc)slice_repr, /* tp_repr */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
391 0, /* tp_as_number */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
392 0, /* tp_as_sequence */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
393 0, /* tp_as_mapping */ |
|
65491
d1def7b2abd2
use helper hash unimplemented function
Benjamin Peterson <benjamin@python.org>
parents:
63775
diff
changeset
|
394 PyObject_HashNotImplemented, /* tp_hash */ |
|
61466
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
395 0, /* tp_call */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
396 0, /* tp_str */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
397 PyObject_GenericGetAttr, /* tp_getattro */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
398 0, /* tp_setattro */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
399 0, /* tp_as_buffer */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
400 Py_TPFLAGS_DEFAULT, /* tp_flags */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
401 slice_doc, /* tp_doc */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
402 0, /* tp_traverse */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
403 0, /* tp_clear */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
404 slice_richcompare, /* tp_richcompare */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
405 0, /* tp_weaklistoffset */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
406 0, /* tp_iter */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
407 0, /* tp_iternext */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
408 slice_methods, /* tp_methods */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
409 slice_members, /* tp_members */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
410 0, /* tp_getset */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
411 0, /* tp_base */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
412 0, /* tp_dict */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
413 0, /* tp_descr_get */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
414 0, /* tp_descr_set */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
415 0, /* tp_dictoffset */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
416 0, /* tp_init */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
417 0, /* tp_alloc */ |
|
cab14be0ada1
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53368
diff
changeset
|
418 slice_new, /* tp_new */ |
| 3837 | 419 }; |
