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

Side by Side Diff: Objects/rangeobject.c

Issue 28376: assertion failure in rangeobject.c
Patch Set: Created 3 years, 6 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 PY_LONG_LONG which 9 This only matters on Win64. Though we could use PY_LONG_LONG which
10 would presumably help perf. 10 would presumably help perf.
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 it->len = (long)ulen; 930 it->len = (long)ulen;
931 it->index = 0; 931 it->index = 0;
932 return (PyObject *)it; 932 return (PyObject *)it;
933 } 933 }
934 934
935 static PyObject * 935 static PyObject *
936 rangeiter_new(PyTypeObject *type, PyObject *args, PyObject *kw) 936 rangeiter_new(PyTypeObject *type, PyObject *args, PyObject *kw)
937 { 937 {
938 long start, stop, step; 938 long start, stop, step;
939 939
940 if (!_PyArg_NoKeywords("rangeiter()", kw)) 940 if (!_PyArg_NoKeywords("range_iterator()", kw)) {
941 return NULL; 941 return NULL;
942 }
942 943
943 if (!PyArg_ParseTuple(args, "lll;rangeiter() requires 3 int arguments", 944 if (!PyArg_ParseTuple(args,
944 &start, &stop, &step)) 945 "lll;range_iterator() requires 3 int arguments",
946 &start, &stop, &step)) {
945 return NULL; 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 }
946 954
947 return fast_range_iter(start, stop, step); 955 return fast_range_iter(start, stop, step);
948 } 956 }
949 957
950 typedef struct { 958 typedef struct {
951 PyObject_HEAD 959 PyObject_HEAD
952 PyObject *index; 960 PyObject *index;
953 PyObject *start; 961 PyObject *start;
954 PyObject *step; 962 PyObject *step;
955 PyObject *len; 963 PyObject *len;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 it->index = PyLong_FromLong(0); 1278 it->index = PyLong_FromLong(0);
1271 if (!it->index) 1279 if (!it->index)
1272 goto create_failure; 1280 goto create_failure;
1273 1281
1274 return (PyObject *)it; 1282 return (PyObject *)it;
1275 1283
1276 create_failure: 1284 create_failure:
1277 Py_DECREF(it); 1285 Py_DECREF(it);
1278 return NULL; 1286 return NULL;
1279 } 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+