]> granicus.if.org Git - python/commitdiff
Issue #27333: Simplified testing step on 0.
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 18 Jun 2016 06:51:55 +0000 (09:51 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 18 Jun 2016 06:51:55 +0000 (09:51 +0300)
Objects/rangeobject.c

index f3ef44cd3628229cb7d92ec6c70319598d2cc08b..284a1008d244b0597d472756d51d2031476c4d96 100644 (file)
@@ -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;