]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#11845: Fix typo in rangeobject.c that caused a crash in compute_slice_indices. ...
authorEzio Melotti <ezio.melotti@gmail.com>
Fri, 15 Apr 2011 05:15:40 +0000 (08:15 +0300)
committerEzio Melotti <ezio.melotti@gmail.com>
Fri, 15 Apr 2011 05:15:40 +0000 (08:15 +0300)
Lib/test/test_range.py
Misc/NEWS
Objects/rangeobject.c

index fc310c15344bdd99b8916f6a5587b750efdde71d..ede07912b0cfb304c4929a5b86f003a46e6a4a0b 100644 (file)
@@ -498,6 +498,15 @@ class RangeTest(unittest.TestCase):
                   ]:
             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)
index 242ec2c33723f84af4d02c697c8e5a4faf744644..8043c8bd9e6b5899f4b69cd79f1c748c508960f3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2.1?
 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.
index cff2ce4741abeb7747fc28963093d21e67a5b6d4..58d373c0b917738b04bcd5bf4bd94c0918ed0b01 100644 (file)
@@ -472,7 +472,7 @@ compute_slice_indices(rangeobject *r, PySliceObject *slice,
                     if (tmp_stop == NULL) goto Fail;
                 } else {
                     tmp_stop = r->length;
-                    Py_INCREF(tmp_start);
+                    Py_INCREF(tmp_stop);
                 }
             }
         }