MutaFix run: more-itertools-002

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

fixedoutcome
37swall time
2model calls
$0.0007API cost
Benchmark ground truth (hidden from the agent)
more_itertools/more.py:661 · operator CMP · function more_itertools/more.py::one
- if too_long is 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.91s
4 failing test(s) · 4 failed, 764 passed · 12.91s
failing tests and errors
tests/test_more.py::OneTests::test_falsy_custom_exception
tests/test_more.py::OneTests::test_too_long
tests/test_more.py::OneTests::test_too_long_default_message
tests/test_more.py::OneTests::test_too_long_does_not_evaluate_repr
tests/test_more.py::OneTests::test_falsy_custom_exception
E   ValueError: Expected exactly one item in iterable, but got 0, 1, and perhaps more.
tests/test_more.py::OneTests::test_too_long
E   TypeError: exceptions must derive from BaseException
trace
+19.28s
re-ran 1 test file(s) with the trace plugin: 4 failing and 616 passing tests, 1 library functions ran in a failing test · 6.26s
tests/test_more.py
retrieve
+19.28s
280 functions indexed, 3 reachable from tests/test_more.py::OneTests::test_falsy_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::one call depth 1 · Ochiai 0.82 (failing 4, passing 2)
  2. more_itertools/more.py::numeric_range.count call depth 1 · Ochiai 0.00 (failing 0, passing 2)
  3. more_itertools/more.py::first call depth 2 · Ochiai 0.00 (failing 0, passing 4)
  4. more_itertools/more.py::strictly_n call depth - · Ochiai 0.00 (failing 0, passing 5)
  5. more_itertools/more.py::only call depth - · Ochiai 0.00 (failing 0, passing 6)
  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::locate call depth - · Ochiai 0.00 (failing 0, passing 13)
  9. more_itertools/recipes.py::grouper call depth - · Ochiai 0.00 (failing 0, passing 0)
  10. more_itertools/more.py::synchronized call depth - · Ochiai 0.00 (failing 0, passing 1)
  11. more_itertools/more.py::extract call depth - · Ochiai 0.00 (failing 0, passing 7)
  12. more_itertools/more.py::constrained_batches call depth - · Ochiai 0.00 (failing 0, passing 7)
  13. more_itertools/more.py::numeric_range.__init__ call depth - · Ochiai 0.00 (failing 0, passing 23)
  14. more_itertools/more.py::gray_product call depth - · Ochiai 0.00 (failing 0, passing 5)
  15. more_itertools/more.py::numeric_range._index_near call depth - · Ochiai 0.00 (failing 0, passing 5)
  16. more_itertools/recipes.py::_batched call depth - · Ochiai 0.00 (failing 0, passing 3)
  17. more_itertools/more.py::rlocate call depth - · Ochiai 0.00 (failing 0, passing 6)
  18. more_itertools/more.py::exactly_n call depth - · Ochiai 0.00 (failing 0, passing 3)
  19. more_itertools/more.py::adjacent call depth - · Ochiai 0.00 (failing 0, passing 10)
  20. more_itertools/more.py::replace call depth - · Ochiai 0.00 (failing 0, passing 8)
rank
+19.28s
spectrum order kept (no model call)
  1. more_itertools/more.py::one
  2. more_itertools/more.py::numeric_range.count
  3. more_itertools/more.py::first
  4. more_itertools/more.py::strictly_n
  5. more_itertools/more.py::only
read
+21.37s
turn 1 · NVIDIA-Nemotron-3-Nano-30B-A3B · 4158 in / 139 out · 2.08s · $0.00028

read more_itertools/more.py::one

The failing test `test_falsy_custom_exception` raises a ValueError about expecting exactly one item in an iterable, but the error message mentions '0, 1, and perhaps more' which suggests the logic in `one` is incorrectly handling falsy exceptions. The test expects a falsy custom exception to be raised when `too_long` is provided, but the current implementation raises a generic ValueError instead. This is likely due to the exception handling logic in the `one` function not properly propagating the custom exception when the iterable has more than one item.

patch
+36.77s
turn 2 · NVIDIA-Nemotron-3-Nano-30B-A3B · 5235 in / 273 out · 2.67s · $0.00038

The test `test_falsy_custom_exception` expects a custom exception (FalsyError) to be raised when `too_long` is provided and the iterable has more than one item. However, the current code only raises `too_long` when it is `None`, which is incorrect. The condition should check if `too_long` is not None to properly raise the custom exception. This fix ensures that when `too_long` is provided (even if it's a falsy exception), it is raised instead of defaulting to a ValueError.

--- a/more_itertools/more.py+++ b/more_itertools/more.py@@ -659,5 +659,5 @@     for first in iterator:         for second in iterator:-            if too_long is 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@@ -659,5 +659,5 @@     for first in iterator:         for second in iterator:-            if too_long is None:+            if too_long is not None:                 raise too_long             raise ValueError(