Issue #27333: Simplified testing step on 0.
This commit is contained in:
parent
cfdfbb4d3c
commit
5d062d7ba3
|
@ -29,17 +29,10 @@ validate_step(PyObject *step)
|
||||||
return PyLong_FromLong(1);
|
return PyLong_FromLong(1);
|
||||||
|
|
||||||
step = PyNumber_Index(step);
|
step = PyNumber_Index(step);
|
||||||
if (step) {
|
if (step && _PyLong_Sign(step) == 0) {
|
||||||
Py_ssize_t istep = PyNumber_AsSsize_t(step, NULL);
|
PyErr_SetString(PyExc_ValueError,
|
||||||
if (istep == -1 && PyErr_Occurred()) {
|
"range() arg 3 must not be zero");
|
||||||
/* Ignore OverflowError, we know the value isn't 0. */
|
Py_CLEAR(step);
|
||||||
PyErr_Clear();
|
|
||||||
}
|
|
||||||
else if (istep == 0) {
|
|
||||||
PyErr_SetString(PyExc_ValueError,
|
|
||||||
"range() arg 3 must not be zero");
|
|
||||||
Py_CLEAR(step);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return step;
|
return step;
|
||||||
|
|
Loading…
Reference in New Issue