From 5d062d7ba34068bed20e8b7486f9973bfafcd203 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 18 Jun 2016 09:51:55 +0300 Subject: [PATCH] Issue #27333: Simplified testing step on 0. --- Objects/rangeobject.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index f3ef44cd362..284a1008d24 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;