diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-08 18:43:11 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-08 18:43:11 (GMT) |
commit | 44759bcf13d6b47323fd4c6e4d62b7146ed0a5b1 (patch) | |
tree | 3d081321de9426abac60ce6fff6f8a355a171176 /Objects | |
parent | 3bd9fde4dfa2e8c50ea10c48a819b1dddafb6dc4 (diff) | |
download | cpython-44759bcf13d6b47323fd4c6e4d62b7146ed0a5b1.zip cpython-44759bcf13d6b47323fd4c6e4d62b7146ed0a5b1.tar.gz cpython-44759bcf13d6b47323fd4c6e4d62b7146ed0a5b1.tar.bz2 |
Issue #28376: The constructor of range_iterator now checks that step is not 0.
Patch by Oren Milman.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/rangeobject.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 288be4f..899697a 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -937,12 +937,20 @@ rangeiter_new(PyTypeObject *type, PyObject *args, PyObject *kw) { long start, stop, step; - if (!_PyArg_NoKeywords("rangeiter()", kw)) + if (!_PyArg_NoKeywords("range_iterator()", kw)) { return NULL; + } - if (!PyArg_ParseTuple(args, "lll;rangeiter() requires 3 int arguments", - &start, &stop, &step)) + if (!PyArg_ParseTuple(args, + "lll;range_iterator() requires 3 int arguments", + &start, &stop, &step)) { + return NULL; + } + if (step == 0) { + PyErr_SetString(PyExc_ValueError, + "range_iterator() arg 3 must not be zero"); return NULL; + } return fast_range_iter(start, stop, step); } |