diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-06-18 06:51:55 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-06-18 06:51:55 (GMT) |
commit | 5d062d7ba34068bed20e8b7486f9973bfafcd203 (patch) | |
tree | 45a5a81e9b356d6ed9f4e1f1064d6d4e8f9f8cfb /Objects | |
parent | cfdfbb4d3c39ee1e728aa80da55c1f25d00be4d1 (diff) | |
download | cpython-5d062d7ba34068bed20e8b7486f9973bfafcd203.zip cpython-5d062d7ba34068bed20e8b7486f9973bfafcd203.tar.gz cpython-5d062d7ba34068bed20e8b7486f9973bfafcd203.tar.bz2 |
Issue #27333: Simplified testing step on 0.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/rangeobject.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index f3ef44c..284a100 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -29,17 +29,10 @@ validate_step(PyObject *step) return PyLong_FromLong(1); step = PyNumber_Index(step); - if (step) { - Py_ssize_t istep = PyNumber_AsSsize_t(step, NULL); - if (istep == -1 && PyErr_Occurred()) { - /* Ignore OverflowError, we know the value isn't 0. */ - PyErr_Clear(); - } - else if (istep == 0) { - PyErr_SetString(PyExc_ValueError, - "range() arg 3 must not be zero"); - Py_CLEAR(step); - } + if (step && _PyLong_Sign(step) == 0) { + PyErr_SetString(PyExc_ValueError, + "range() arg 3 must not be zero"); + Py_CLEAR(step); } return step; |