Skip to content

Commit 9e9d610

Browse files
authored
Merge pull request #3953 from Yaminyam/fix/range-iter
Fix: `range` beyond the isize range
2 parents 098a709 + 57a5470 commit 9e9d610

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,12 @@ 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())
481-
{
479+
if let (Some(start), Some(step), Some(_), Some(_)) = (
480+
start.to_isize(),
481+
step.to_isize(),
482+
stop.to_isize(),
483+
(start + step).to_isize(),
484+
) {
482485
Ok(PyRangeIterator {
483486
index: AtomicCell::new(0),
484487
start,

0 commit comments

Comments
 (0)