One function
iterate in more-itertools/more-itertools
The author described this change as “Issue #707: fix ``iterate()`` to enable ``func`` to raise StopIteration”. It counts as a record because the check below fails on the code as it stood at 7c1b6482a and passes on cd0a3a87d, with nothing else changed between the two runs.
Fix saved2023-04-19
Sharing licenceMIT · LICENSE
Change size+4 −1
What the code was meant to do, written into the code itself as a docstring
Return `start`, `func(start)`, `func(func(start))`, ...
The change
| 8 | 8 | """ | |
| 9 | 9 | while True: | |
| 10 | 10 | yield start | |
| 11 | - | start = func(start) | |
| 11 | + | try: | |
| 12 | + | start = func(start) | |
| 13 | + | except StopIteration: | |
| 14 | + | break |
The check that tells the two apart
fail→pass·tests/test_more.py::IterateTests::test_func_controls_iteration_stop
Check file tests/test_more.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it7c1b6482a00cb9c1f76061c12be192ed5043e5ea
Broken version dated2023-04-11
Modulemore_itertools.more
Units changediterate
Fingerprint37d9ffc578a058d9
Checked2026-08-17 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in more-itertools/more-itertools
- 2026-07-19chunked
- 2026-07-03sliced
- 2026-06-30tail
- 2026-06-30interleave_evenly
- 2026-04-01windowed
- 2026-01-02nth_combination_with_replacement