MutaFix run: more-itertools-012

ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory

fixedoutcome
38swall time
2model calls
$0.0007API cost
Benchmark ground truth (hidden from the agent)
more_itertools/more.py:3693 · operator NEGCOND · function more_itertools/more.py::only
- if not (too_long is not None):   (injected bug)+ if too_long is not None:   (original)
retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore yes

Trace

reproduce
+12.88s
6 failing test(s) · 6 failed, 762 passed · 12.88s
failing tests and errors
tests/test_more.py::OnlyTests::test_custom_exception
tests/test_more.py::OnlyTests::test_custom_value
tests/test_more.py::OnlyTests::test_default_exception_message
tests/test_more.py::OnlyTests::test_defaults
tests/test_more.py::OnlyTests::test_falsy_custom_exception
tests/test_more.py::OnlyTests::test_too_long_does_not_evaluate_repr
tests/test_more.py::OnlyTests::test_custom_exception
E   ValueError: Expected exactly one item in iterable, but got 1, 2, and perhaps more.
tests/test_more.py::OnlyTests::test_custom_value
E   TypeError: exceptions must derive from BaseException
trace
+19.37s
re-ran 1 test file(s) with the trace plugin: 6 failing and 614 passing tests, 1 library functions ran in a failing test · 6.4s
tests/test_more.py
retrieve
+19.37s
280 functions indexed, 2 reachable from tests/test_more.py::OnlyTests::test_custom_exception in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.
candidates in retriever order
  1. more_itertools/more.py::only call depth 1 · Ochiai 1.00 (failing 6, passing 0)
  2. more_itertools/more.py::first call depth 2 · Ochiai 0.00 (failing 0, passing 4)
  3. more_itertools/more.py::one call depth - · Ochiai 0.00 (failing 0, passing 6)
  4. more_itertools/more.py::strictly_n call depth - · Ochiai 0.00 (failing 0, passing 5)
  5. more_itertools/more.py::iter_suppress call depth - · Ochiai 0.00 (failing 0, passing 8)
  6. more_itertools/more.py::filter_except call depth - · Ochiai 0.00 (failing 0, passing 5)
  7. more_itertools/more.py::map_except call depth - · Ochiai 0.00 (failing 0, passing 4)
  8. more_itertools/more.py::numeric_range.__init__ call depth - · Ochiai 0.00 (failing 0, passing 23)
  9. more_itertools/more.py::callback_iter.result call depth - · Ochiai 0.00 (failing 0, passing 5)
  10. more_itertools/more.py::numeric_range._index_near call depth - · Ochiai 0.00 (failing 0, passing 5)
  11. more_itertools/more.py::extract call depth - · Ochiai 0.00 (failing 0, passing 7)
  12. more_itertools/recipes.py::grouper call depth - · Ochiai 0.00 (failing 0, passing 0)
  13. more_itertools/more.py::gray_product call depth - · Ochiai 0.00 (failing 0, passing 5)
  14. more_itertools/more.py::distinct_permutations call depth - · Ochiai 0.00 (failing 0, passing 7)
  15. more_itertools/more.py::concurrent_tee call depth - · Ochiai 0.00 (failing 0, passing 1)
  16. more_itertools/more.py::zip_offset call depth - · Ochiai 0.00 (failing 0, passing 6)
  17. more_itertools/more.py::iequals call depth - · Ochiai 0.00 (failing 0, passing 9)
  18. more_itertools/more.py::locate call depth - · Ochiai 0.00 (failing 0, passing 13)
  19. more_itertools/recipes.py::sliding_window call depth - · Ochiai 0.00 (failing 0, passing 0)
  20. more_itertools/more.py::substrings call depth - · Ochiai 0.00 (failing 0, passing 4)
rank
+19.37s
spectrum order kept (no model call)
  1. more_itertools/more.py::only
  2. more_itertools/more.py::first
  3. more_itertools/more.py::one
  4. more_itertools/more.py::strictly_n
  5. more_itertools/more.py::iter_suppress
read
+22.16s
turn 1 · NVIDIA-Nemotron-3-Nano-30B-A3B · 4422 in / 126 out · 2.79s · $0.00030

read more_itertools/more.py::only

The failing tests indicate issues with the `only` function's handling of the `too_long` parameter and exception raising. The source code of `only` (candidate 1) contains logic that raises a `ValueError` with a specific message format when more than one item is found, but the tests expect a `RuntimeError` (or custom exception) to be raised when `too_long` is provided. The bug likely lies in how the function handles the `too_long` parameter and raises exceptions.

patch
+38.35s
turn 2 · NVIDIA-Nemotron-3-Nano-30B-A3B · 5133 in / 256 out · 4.16s · $0.00037

The bug is in the condition checking for `too_long`. The original code uses `if not (too_long is not None)` which is equivalent to `if too_long is None`, causing the exception to be raised only when `too_long` is None. This is incorrect because the intent is to raise `too_long` when it is provided (i.e., when it is not None). The fix simplifies the condition to `if too_long is not None` to correctly raise the provided exception when `too_long` is specified.

--- a/more_itertools/more.py+++ b/more_itertools/more.py@@ -3691,5 +3691,5 @@     for first in iterator:         for second in iterator:-            if not (too_long is not None):+            if too_long is not None:                 raise too_long             raise ValueError(

tests: all tests pass 768 passed

Final patch

--- a/more_itertools/more.py+++ b/more_itertools/more.py@@ -3691,5 +3691,5 @@     for first in iterator:         for second in iterator:-            if not (too_long is not None):+            if too_long is not None:                 raise too_long             raise ValueError(