Skip to content

Commit 8f0e40f

Browse files
hrchuyouknowone
authored andcommitted
Fix test_long::test_huge_rshift
1 parent 4a6df6b commit 8f0e40f

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

Lib/test/test_long.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,6 @@ def test_huge_lshift_of_zero(self):
953953
def test_huge_lshift(self, size):
954954
self.assertEqual(1 << (sys.maxsize + 1000), 1 << 1000 << sys.maxsize)
955955

956-
# TODO: RUSTPYTHON
957-
@unittest.expectedFailure
958956
def test_huge_rshift(self):
959957
self.assertEqual(42 >> (1 << 1000), 0)
960958
self.assertEqual((-42) >> (1 << 1000), -1)

vm/src/builtins/int.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ where
166166
} else if int1.is_zero() {
167167
Ok(vm.ctx.new_int(0).into())
168168
} else {
169-
let int2 = int2.to_usize().ok_or_else(|| {
170-
vm.new_overflow_error("the number is too large to convert to int".to_owned())
171-
})?;
169+
let int2 = int2.min(&BigInt::from(usize::MAX)).to_usize().unwrap();
172170
Ok(vm.ctx.new_int(shift_op(int1, int2)).into())
173171
}
174172
}

0 commit comments

Comments
 (0)