diff options
author | Alexey Izbyshev <izbyshev@ispras.ru> | 2018-08-24 04:39:45 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2018-08-24 04:39:45 (GMT) |
commit | 7ecae3ca0bda3cacf3b0125bae0bc718a17cc071 (patch) | |
tree | fd98197f690982b912bab8acc40ee4046357d8aa /Objects | |
parent | 2b824b2538c4a5f9f520c5de8a1eae5a0c181a94 (diff) | |
download | cpython-7ecae3ca0bda3cacf3b0125bae0bc718a17cc071.zip cpython-7ecae3ca0bda3cacf3b0125bae0bc718a17cc071.tar.gz cpython-7ecae3ca0bda3cacf3b0125bae0bc718a17cc071.tar.bz2 |
closes bpo-34468: Objects/rangeobject.c: Fix an always-false condition in range_repr() (GH-8880)
Also, propagate the error from PyNumber_AsSsize_t() because we don't care
only about OverflowError which is not reported if the second argument is NULL.
Reported by Svace static analyzer.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/rangeobject.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 28a244e..2b00a17 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -575,11 +575,11 @@ range_repr(rangeobject *r) Py_ssize_t istep; /* Check for special case values for printing. We don't always - need the step value. We don't care about errors - (it means overflow), so clear the errors. */ + need the step value. We don't care about overflow. */ istep = PyNumber_AsSsize_t(r->step, NULL); - if (istep != 1 || (istep == -1 && PyErr_Occurred())) { - PyErr_Clear(); + if (istep == -1 && PyErr_Occurred()) { + assert(!PyErr_ExceptionMatches(PyExc_OverflowError)); + return NULL; } if (istep == 1) |