[Python-checkins] cpython: Issue #27333: Simplified testing step on 0.
serhiy.storchaka
python-checkins at python.org
Sat Jun 18 02:52:47 EDT 2016
https://hg.python.org/cpython/rev/4fbcd58df1a0
changeset: 102080:4fbcd58df1a0
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Jun 18 09:51:55 2016 +0300
summary:
Issue #27333: Simplified testing step on 0.
files:
Objects/rangeobject.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -29,17 +29,10 @@
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;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list