MutaFix run: toolz-011
ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory
- if not (len(seqs) == 0): (injected bug)+ if len(seqs) == 0: (original)retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore no
Trace
failing tests and errors
toolz/tests/test_itertoolz.py::test_merge_sortedtoolz/tests/test_itertoolz.py::test_merge_sorted
E assert [] == [1, 1, 2, 2, 3, 3] E E Right contains 6 more items, first extra item: 1 E Use -v to get more diff
toolz/tests/test_itertoolz.py::test_merge_sorted in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.candidates in retriever order
toolz/itertoolz.py::merge_sortedtoolz/itertoolz.py::jointoolz/functoolz.py::identitytoolz/itertoolz.py::_merge_sorted_binary_keytoolz/itertoolz.py::gettoolz/itertoolz.py::_merge_sorted_binarytoolz/itertoolz.py::groupbytoolz/itertoolz.py::gettertoolz/itertoolz.py::_gettoolz/itertoolz.py::difftoolz/itertoolz.py::plucktoolz/dicttoolz.py::merge_withtoolz/dicttoolz.py::get_intoolz/curried/exceptions.py::mergetoolz/curried/exceptions.py::merge_withtoolz/itertoolz.py::partition_alltoolz/functoolz.py::_check_sigspectoolz/itertoolz.py::topktoolz/functoolz.py::composetoolz/itertoolz.py::concat
toolz/itertoolz.py::merge_sortedtoolz/itertoolz.py::jointoolz/functoolz.py::identitytoolz/itertoolz.py::_merge_sorted_binary_keytoolz/itertoolz.py::get
read toolz/itertoolz.py::merge_sorted
The failing test is merge_sorted, and the source shows the implementation of merge_sorted function. The bug appears to be in the condition `if not (len(seqs) == 0)` which should be `if not seqs` to correctly check for empty input. This causes incorrect handling of empty sequences.
The condition `if not (len(seqs) == 0)` is incorrect because it returns False when seqs is empty (since len(seqs) == 0 is True, so not True is False), but it should return True when seqs is empty. The correct way to check for empty *args is `if not seqs` which directly evaluates the truthiness of the tuple. This bug causes the function to return an empty iterator when called with no arguments, but the test expects it to return an empty list when called with no arguments (as seen in the test case `assert list(merge_sorted()) == []`). The patch fixes the condition to properly handle empty input.
--- a/toolz/itertoolz.py+++ b/toolz/itertoolz.py@@ -121,5 +121,5 @@ [2, 1, 3, 3] """- if not (len(seqs) == 0):+ if not seqs: return iter([]) elif len(seqs) == 1:
tests: all tests pass
Final patch
--- a/toolz/itertoolz.py+++ b/toolz/itertoolz.py@@ -121,5 +121,5 @@ [2, 1, 3, 3] """- if not (len(seqs) == 0):+ if not seqs: return iter([]) elif len(seqs) == 1: