Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(17)

Side by Side Diff: Objects/rangeobject.c

Issue 28376: assertion failure in rangeobject.c
Patch Set: Created 3 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_range.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Range object implementation */ 1 /* Range object implementation */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 #include "structmember.h" 4 #include "structmember.h"
5 5
6 /* Support objects whose length is > PY_SSIZE_T_MAX. 6 /* Support objects whose length is > PY_SSIZE_T_MAX.
7 7
8 This could be sped up for small PyLongs if they fit in a Py_ssize_t. 8 This could be sped up for small PyLongs if they fit in a Py_ssize_t.
9 This only matters on Win64. Though we could use long long which 9 This only matters on Win64. Though we could use long long which
10 would presumably help perf. 10 would presumably help perf.
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 it->len = (long)ulen; 923 it->len = (long)ulen;
924 it->index = 0; 924 it->index = 0;
925 return (PyObject *)it; 925 return (PyObject *)it;
926 } 926 }
927 927
928 static PyObject * 928 static PyObject *
929 rangeiter_new(PyTypeObject *type, PyObject *args, PyObject *kw) 929 rangeiter_new(PyTypeObject *type, PyObject *args, PyObject *kw)
930 { 930 {
931 long start, stop, step; 931 long start, stop, step;
932 932
933 if (!_PyArg_NoKeywords("rangeiter()", kw)) 933 if (PyErr_WarnEx(PyExc_DeprecationWarning,
934 "range_iterator(): creating instances of range_iterator "
935 "by calling range_iterator type is deprecated",
936 1)) {
934 return NULL; 937 return NULL;
938 }
935 939
936 if (!PyArg_ParseTuple(args, "lll;rangeiter() requires 3 int arguments", 940 if (!_PyArg_NoKeywords("range_iterator()", kw)) {
937 &start, &stop, &step))
938 return NULL; 941 return NULL;
942 }
943
944 if (!PyArg_ParseTuple(args,
945 "lll;range_iterator() requires 3 int arguments",
946 &start, &stop, &step)) {
947 return NULL;
948 }
949 if (step == 0) {
950 PyErr_SetString(PyExc_ValueError,
951 "range_iterator() arg 3 must not be zero");
952 return NULL;
953 }
939 954
940 return fast_range_iter(start, stop, step); 955 return fast_range_iter(start, stop, step);
941 } 956 }
942 957
943 typedef struct { 958 typedef struct {
944 PyObject_HEAD 959 PyObject_HEAD
945 PyObject *index; 960 PyObject *index;
946 PyObject *start; 961 PyObject *start;
947 PyObject *step; 962 PyObject *step;
948 PyObject *len; 963 PyObject *len;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 it->index = PyLong_FromLong(0); 1278 it->index = PyLong_FromLong(0);
1264 if (!it->index) 1279 if (!it->index)
1265 goto create_failure; 1280 goto create_failure;
1266 1281
1267 return (PyObject *)it; 1282 return (PyObject *)it;
1268 1283
1269 create_failure: 1284 create_failure:
1270 Py_DECREF(it); 1285 Py_DECREF(it);
1271 return NULL; 1286 return NULL;
1272 } 1287 }
OLDNEW
« no previous file with comments | « Lib/test/test_range.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+