Issue #27333: Simplified testing step on 0.

This commit is contained in:
Serhiy Storchaka 2016-06-18 09:51:55 +03:00
parent cfdfbb4d3c
commit 5d062d7ba3
1 changed files with 4 additions and 11 deletions

View File

@ -29,18 +29,11 @@ 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) {
if (step && _PyLong_Sign(step) == 0) {
PyErr_SetString(PyExc_ValueError,
"range() arg 3 must not be zero");
Py_CLEAR(step);
}
}
return step;
}