Index: Objects/rangeobject.c =================================================================== --- Objects/rangeobject.c (revision 67537) +++ Objects/rangeobject.c (working copy) @@ -30,8 +30,7 @@ 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(); + Py_CLEAR(step); } else if (istep == 0) { PyErr_SetString(PyExc_ValueError, @@ -76,8 +75,11 @@ /* Convert borrowed refs to owned refs */ start = PyNumber_Index(start); stop = PyNumber_Index(stop); + if (!start || !stop) + goto Fail; + step = validate_step(step); - if (!start || !stop || !step) + if (!step) goto Fail; }