MutaFix run: more-itertools-002
ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory
- 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
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_reprtests/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
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
more_itertools/more.py::onemore_itertools/more.py::numeric_range.countmore_itertools/more.py::firstmore_itertools/more.py::strictly_nmore_itertools/more.py::onlymore_itertools/more.py::filter_exceptmore_itertools/more.py::map_exceptmore_itertools/more.py::locatemore_itertools/recipes.py::groupermore_itertools/more.py::synchronizedmore_itertools/more.py::extractmore_itertools/more.py::constrained_batchesmore_itertools/more.py::numeric_range.__init__more_itertools/more.py::gray_productmore_itertools/more.py::numeric_range._index_nearmore_itertools/recipes.py::_batchedmore_itertools/more.py::rlocatemore_itertools/more.py::exactly_nmore_itertools/more.py::adjacentmore_itertools/more.py::replace
more_itertools/more.py::onemore_itertools/more.py::numeric_range.countmore_itertools/more.py::firstmore_itertools/more.py::strictly_nmore_itertools/more.py::only
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.
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
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(