MutaFix run: sortedcontainers-002
ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory
- if idx != len_sublist: (injected bug)+ if idx == len_sublist: (original)retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore yes
Trace
failing tests and errors
tests/test_coverage_sortedkeylist_modulo.py::test_count tests/test_coverage_sortedkeylist_negate.py::test_count tests/test_stress_sortedkeylist.py::test_stresstests/test_coverage_sortedkeylist_modulo.py::test_count
E IndexError: list index out of rangetests/test_coverage_sortedkeylist_negate.py::test_count
E IndexError: list index out of range
tests/test_coverage_sortedkeylist_modulo.py::test_count in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.candidates in retriever order
src/sortedcontainers/sortedlist.py::SortedKeyList.countsrc/sortedcontainers/sortedlist.py::SortedKeyList.__repr__src/sortedcontainers/sortedlist.py::identitysrc/sortedcontainers/sortedlist.py::SortedKeyList.addsrc/sortedcontainers/sortedlist.py::SortedKeyList._expandsrc/sortedcontainers/sortedlist.py::SortedKeyList.bisect_leftsrc/sortedcontainers/sortedlist.py::SortedList.__imul__src/sortedcontainers/sortedlist.py::SortedList.__reversed__src/sortedcontainers/sortedlist.py::SortedKeyList.bisect_key_leftsrc/sortedcontainers/sortedlist.py::SortedKeyList._checksrc/sortedcontainers/sortedlist.py::SortedKeyList.__mul__src/sortedcontainers/sortedlist.py::SortedKeyList.__contains__src/sortedcontainers/sortedlist.py::SortedKeyList.bisect_rightsrc/sortedcontainers/sortedlist.py::SortedKeyList.discardsrc/sortedcontainers/sortedlist.py::SortedList.__delitem__src/sortedcontainers/sortedlist.py::SortedList.popsrc/sortedcontainers/sortedlist.py::SortedKeyList.bisect_key_rightsrc/sortedcontainers/sortedlist.py::SortedList.__len__src/sortedcontainers/sortedlist.py::SortedKeyList.clearsrc/sortedcontainers/sortedlist.py::SortedList.__iter__
src/sortedcontainers/sortedlist.py::SortedKeyList.countsrc/sortedcontainers/sortedlist.py::SortedKeyList.__repr__src/sortedcontainers/sortedlist.py::identitysrc/sortedcontainers/sortedlist.py::SortedKeyList.addsrc/sortedcontainers/sortedlist.py::SortedKeyList._expand
read src/sortedcontainers/sortedlist.py::SortedKeyList.count
The failing tests report an IndexError in count() and incorrect count results. Candidate 1 is the only function directly related to counting elements in a SortedKeyList, and its logic involves bisect operations and traversing sublists that could cause index errors if bounds are miscalculated.
The bug is in the condition that checks whether to continue traversing sublists. The original code uses `if idx != len_sublist:` to decide whether to move to the next sublist, but this causes an off-by-one error when `idx` equals `len_sublist`, leading to an IndexError when accessing `_keys[pos][idx]` or `_lists[pos][idx]`. The condition should be `if idx == len_sublist:` to correctly trigger the move to the next sublist when the current one has been fully processed. This matches the fault localization model for candidate 1 and resolves the IndexError in the failing tests.
--- a/src/sortedcontainers/sortedlist.py+++ b/src/sortedcontainers/sortedlist.py@@ -2281,5 +2281,5 @@ total += 1 idx += 1- if idx != len_sublist:+ if idx == len_sublist: pos += 1 if pos == len_keys:
tests: all tests pass
Final patch
--- a/src/sortedcontainers/sortedlist.py+++ b/src/sortedcontainers/sortedlist.py@@ -2281,5 +2281,5 @@ total += 1 idx += 1- if idx != len_sublist:+ if idx == len_sublist: pos += 1 if pos == len_keys: