One function

split_iter in mahmoud/boltons

The author described this change as Fix split maxsplit zero handling. It counts as a record because the check below fails on the code as it stood at 3970a80f6 and passes on 4aa77cddb, with nothing else changed between the two runs.

Fix saved2026-06-19
Sharing licenceBSD-2-Clause · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a docstring

Splits an iterable based on a separator, *sep*, a max of *maxsplit* times (no max by default). *sep* can be: * a single value * an iterable of separators * a single-argument callable that returns True when a separator is encountered `split_iter()` yields lists of non-separator values. A separator will never appear in the output. Note that `split_iter` is based on :func:`str.split`, so if *sep* is `None`, `split()` **groups** separators. If empty lists are desired between two contiguous `None` values, simply use `sep=[None]`: Using a callable separator: See :func:`split` for a list-returning version.

The change

3838 if maxsplit is not None:
3939 maxsplit = int(maxsplit)
4040 if maxsplit == 0:
41- yield [src]
41+ yield list(src)
4242 return
4343
4444 if callable(sep):

The check that tells the two apart

failpass·tests/test_iterutils.py::TestSplit::test_maxsplit_zero_returns_unsplit_values

Check file tests/test_iterutils.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 it3970a80f63807392e512340c25dc2db473bcba70
Broken version dated2026-06-19
Moduleboltons.iterutils
Units changedsplit_iter
Fingerprint432e61ef5df2ed72
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in mahmoud/boltons