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

2626 if pred(item) and buf:
2727 yield buf
2828 if maxsplit == 1:
29- yield list(it)
29+ buf = list(it)
30+ if buf:
31+ yield buf
3032 return
3133 buf = []
3234 maxsplit -= 1

The check that tells the two apart

failpass·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