One function
split_after in more-itertools/more-itertools
The author described this change as “Fix issue 658 for split_after”. It counts as a record because the check below fails on the code as it stood at 6793bd3e4 and passes on 9245cd04c, with nothing else changed between the two runs.
Fix saved2022-11-22
Sharing licenceMIT · LICENSE
Change size+3 −1
What the code was meant to do, written into the code itself as a docstring
Yield lists of items from *iterable*, where each list ends with an item where callable *pred* returns `True`: At most *maxsplit* splits are done. If *maxsplit* is not specified or -1, then there is no limit on the number of splits:
The change
| 26 | 26 | if pred(item) and buf: | |
| 27 | 27 | yield buf | |
| 28 | 28 | if maxsplit == 1: | |
| 29 | - | yield list(it) | |
| 29 | + | buf = list(it) | |
| 30 | + | if buf: | |
| 31 | + | yield buf | |
| 30 | 32 | return | |
| 31 | 33 | buf = [] | |
| 32 | 34 | maxsplit -= 1 |
The check that tells the two apart
fail→pass·tests/test_more.py::SplitAfterTest::test_max_split
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 it6793bd3e4ed15318746ed2511733f12a9932eb64
Broken version dated2022-11-09
Modulemore_itertools.more
Units changedsplit_after
Fingerprint2d1df6d507bdf5d1
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