Skip to content

Commit

Permalink
python#11845: Fix typo in rangeobject.c that caused a crash in comput…
Browse files Browse the repository at this point in the history
…e_slice_indices. Patch by Daniel Urban.
  • Loading branch information
ezio-melotti committed Apr 15, 2011
1 parent 34d204b commit 982ef4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Lib/test/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,15 @@ def test_reverse_iteration(self):
]:
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)
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Objects/rangeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 982ef4e

Please sign in to comment.