One function
spy in more-itertools/more-itertools
The author described this change as “Fix spy to make returned iterable immutable”. It counts as a record because the check below fails on the code as it stood at c0465331c and passes on 62411c161, with nothing else changed between the two runs.
Fix saved2020-03-29
Sharing licenceMIT · LICENSE
Change size+1 −1
What the code was meant to do, written into the code itself as a docstring
Return a 2-tuple with a list containing the first *n* elements of *iterable*, and an iterator with the same items as *iterable*. This allows you to "look ahead" at the items in the iterable without advancing it. There is one item in the list by default: You may use unpacking to retrieve items instead of lists: The number of items requested can be larger than the number of items in the iterable:
The change
| 38 | 38 | it = iter(iterable) | |
| 39 | 39 | head = take(n, it) | |
| 40 | 40 | ||
| 41 | - | return head, chain(head, it) | |
| 41 | + | return head.copy(), chain(head, it) |
The check that tells the two apart
fail→pass·tests/test_more.py::SpyTests::test_immutable
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 itc0465331cbc0d882cd7dce5c0bd19aaf46dfb968
Broken version dated2020-03-29
Modulemore_itertools.more
Units changedspy
Fingerprintc5b8f23c1638de5f
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