Skip to content

Commit 9e3079c

Browse files
committed
Fix: range beyond the isize range
* Check if start + step is greater than sys.maxsize
1 parent 098a709 commit 9e3079c

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

Lib/test/test_range.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,6 @@ def test_pickling(self):
375375
self.assertEqual(list(pickle.loads(pickle.dumps(r, proto))),
376376
list(r))
377377

378-
# TODO: RUSTPYTHON
379-
@unittest.expectedFailure
380378
def test_iterator_pickling(self):
381379
testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1), (13, 21, 3),
382380
(-2, 2, 2)]

vm/src/builtins/range.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ impl Iterable for PyRange {
476476
zelf.step.as_bigint(),
477477
zelf.len(),
478478
);
479-
if let (Some(start), Some(step), Some(_)) =
480-
(start.to_isize(), step.to_isize(), stop.to_isize())
479+
if let (Some(start), Some(step), Some(_), Some(_)) =
480+
(start.to_isize(), step.to_isize(), stop.to_isize(), (start + step).to_isize())
481481
{
482482
Ok(PyRangeIterator {
483483
index: AtomicCell::new(0),

0 commit comments

Comments
 (0)