[Python-checkins] cpython (3.2): #11845: Fix typo in rangeobject.c that caused a crash in compute_slice_indices.

ezio.melotti python-checkins at python.org
Fri Apr 15 07:19:44 CEST 2011


http://hg.python.org/cpython/rev/8025fb83dece
changeset: 69359:8025fb83dece
branch: 3.2
parent: 69357:1e315794ac8c
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Fri Apr 15 08:15:40 2011 +0300
summary:
 #11845: Fix typo in rangeobject.c that caused a crash in compute_slice_indices. Patch by Daniel Urban.
files:
 Lib/test/test_range.py | 9 +++++++++
 Misc/NEWS | 3 +++
 Objects/rangeobject.c | 2 +-
 3 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -498,6 +498,15 @@
 ]:
 self.assertEqual(list(reversed(r)), list(r)[::-1])
 
+ def test_issue11845(self):
+ r = range(*slice(1, 18, 2).indices(20))
+ values = {None, 0, 1, -1, 2, -2, 5, -5, 19, -19,
+ 20, -20, 21, -21, 30, -30, 99, -99}
+ for i in values:
+ for j in values:
+ for k in values - {0}:
+ r[i:j:k]
+
 
 def test_main():
 test.support.run_unittest(RangeTest)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #11845: Fix typo in rangeobject.c that caused a crash in
+ compute_slice_indices. Patch by Daniel Urban.
+
 - Issue #11650: PyOS_StdioReadline() retries fgets() if it was interrupted
 (EINTR), for example if the program is stopped with CTRL+z on Mac OS X. Patch
 written by Charles-Francois Natali.
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -472,7 +472,7 @@
 if (tmp_stop == NULL) goto Fail;
 } else {
 tmp_stop = r->length;
- Py_INCREF(tmp_start);
+ Py_INCREF(tmp_stop);
 }
 }
 }
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /