One function

split_before in more-itertools/more-itertools

The author described this change as Fix split_before for an empty collections.. It counts as a record because the check below fails on the code as it stood at c7e73ffbf and passes on 2e81a562f, with nothing else changed between the two runs.

Fix saved2021-03-10
Sharing licenceMIT · LICENSE
Change size+2 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 just before an item for which 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

2929 buf = []
3030 maxsplit -= 1
3131 buf.append(item)
32- yield buf
32+ if buf:
33+ yield buf

The check that tells the two apart

failpass·tests/test_more.py::SplitBeforeTest::test_empty_collection

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 itc7e73ffbf9c7e15969f9ed301d0431770061ab90
Broken version dated2021-03-06
Modulemore_itertools.more
Units changedsplit_before
Fingerprint2766ba6ae7a57003
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