Skip to content

Commit d9f76ac

Browse files
committed
itertools: fix count() repr to show float step 1.0
Assisted-by: Claude Code:claude-opus-4-8
1 parent 9c064c1 commit d9f76ac

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

Lib/test/test_itertools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,6 @@ def test_count(self):
538538
#check proper internal error handling for large "step' sizes
539539
count(1, maxsize+5); sys.exc_info()
540540

541-
@unittest.expectedFailure # TODO: RUSTPYTHON; 'count(10.5)' != 'count(10.5, 1.0)'
542541
def test_count_with_step(self):
543542
self.assertEqual(lzip('abc',count(2,3)), [('a', 2), ('b', 5), ('c', 8)])
544543
self.assertEqual(lzip('abc',count(start=2,step=3)),

crates/vm/src/stdlib/itertools.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ mod decl {
225225
let step = &zelf.step;
226226
let mut result = Wtf8Buf::from("count(");
227227
result.push_wtf8(cur_repr.as_wtf8());
228-
if !vm.bool_eq(step, vm.ctx.new_int(1).as_object())? {
228+
let step_is_int_one = step.fast_isinstance(vm.ctx.types.int_type)
229+
&& vm.bool_eq(step, vm.ctx.new_int(1).as_object())?;
230+
if !step_is_int_one {
229231
result.push_str(", ");
230232
result.push_wtf8(step.repr(vm)?.as_wtf8());
231233
}

0 commit comments

Comments
 (0)