MutaFix run: sortedcontainers-011

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

fixedoutcome
9swall time
2model calls
$0.0005API cost
Benchmark ground truth (hidden from the agent)
src/sortedcontainers/sorteddict.py:286 · operator NEGCOND · function src/sortedcontainers/sorteddict.py::SortedDict.__ror__
- if not (not isinstance(other, Mapping)):   (injected bug)+ if not isinstance(other, Mapping):   (original)
retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore yes

Trace

reproduce
+2.48s
1 failing test(s) · 1 failed, 298 passed · 2.48s
failing tests and errors
tests/test_coverage_sorteddict.py::test_ror_not_implemented
tests/test_coverage_sorteddict.py::test_ror_not_implemented
E   AttributeError: 'CustomOr' object has no attribute 'items'
trace
+2.9s
re-ran 1 test file(s) with the trace plugin: 2 failing and 56 passing tests, 6 library functions ran in a failing test · 0.39s
tests/test_coverage_sorteddict.py
retrieve
+2.9s
129 functions indexed, 89 reachable from tests/test_coverage_sorteddict.py::test_ror_not_implemented in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.
candidates in retriever order
  1. src/sortedcontainers/sorteddict.py::SortedDict.__ror__ call depth 1 · Ochiai 0.50 (failing 1, passing 1)
  2. src/sortedcontainers/sortedlist.py::SortedList.__init__ call depth 2 · Ochiai 0.20 (failing 2, passing 46)
  3. src/sortedcontainers/sortedlist.py::SortedList.update call depth 2 · Ochiai 0.20 (failing 2, passing 46)
  4. src/sortedcontainers/sorteddict.py::SortedDict.__init__ call depth 1 · Ochiai 0.19 (failing 2, passing 55)
  5. src/sortedcontainers/sortedlist.py::SortedList.__new__ call depth 2 · Ochiai 0.19 (failing 2, passing 55)
  6. src/sortedcontainers/sorteddict.py::SortedDict.update call depth 2 · Ochiai 0.19 (failing 2, passing 55)
  7. src/sortedcontainers/sorteddict.py::SortedDict.__reduce__ call depth 1 · Ochiai 0.00 (failing 0, passing 1)
  8. src/sortedcontainers/sorteddict.py::SortedDict.__delitem__ call depth 1 · Ochiai 0.00 (failing 0, passing 2)
  9. src/sortedcontainers/sorteddict.py::SortedDict.__repr__ call depth 1 · Ochiai 0.00 (failing 0, passing 6)
  10. src/sortedcontainers/sorteddict.py::SortedDict.__or__ call depth 1 · Ochiai 0.00 (failing 0, passing 2)
  11. src/sortedcontainers/sorteddict.py::SortedDict.__iter__ call depth 1 · Ochiai 0.00 (failing 0, passing 18)
  12. src/sortedcontainers/sorteddict.py::SortedDict.__reversed__ call depth 1 · Ochiai 0.00 (failing 0, passing 2)
  13. src/sortedcontainers/sorteddict.py::SortedDict.__setitem__ call depth 1 · Ochiai 0.00 (failing 0, passing 4)
  14. src/sortedcontainers/sorteddict.py::SortedDict.__ior__ call depth 1 · Ochiai 0.00 (failing 0, passing 1)
  15. src/sortedcontainers/sortedlist.py::SortedList.__setitem__ call depth 2 · Ochiai 0.00 (failing 0, passing 0)
  16. src/sortedcontainers/sorteddict.py::SortedDict.pop call depth 2 · Ochiai 0.00 (failing 0, passing 2)
  17. src/sortedcontainers/sorteddict.py::SortedDict.items call depth 2 · Ochiai 0.00 (failing 0, passing 9)
  18. src/sortedcontainers/sorteddict.py::SortedDict.clear call depth 2 · Ochiai 0.00 (failing 0, passing 3)
  19. src/sortedcontainers/sorteddict.py::SortedDict.copy call depth 2 · Ochiai 0.00 (failing 0, passing 2)
  20. src/sortedcontainers/sortedset.py::SortedSet.remove call depth 2 · Ochiai 0.00 (failing 0, passing 0)
rank
+2.9s
spectrum order kept (no model call)
  1. src/sortedcontainers/sorteddict.py::SortedDict.__ror__
  2. src/sortedcontainers/sortedlist.py::SortedList.__init__
  3. src/sortedcontainers/sortedlist.py::SortedList.update
  4. src/sortedcontainers/sorteddict.py::SortedDict.__init__
  5. src/sortedcontainers/sortedlist.py::SortedList.__new__
read
+4.39s
turn 1 · NVIDIA-Nemotron-3-Nano-30B-A3B · 3650 in / 139 out · 1.49s · $0.00025

read src/sortedcontainers/sorteddict.py::SortedDict.__ror__

The failing test expects a TypeError when using the | operator with CustomOr and SortedDict, but the current __ror__ implementation tries to call .items() on other, which fails if other is not a Mapping. The error message shows 'CustomOr object has no attribute items', indicating that the code is trying to access .items() on other without checking if it has that attribute. The condition checks for Mapping but uses 'not isinstance(other, Mapping)' which would be true for CustomOr, causing the function to proceed and attempt to call .items() on it.

patch
+9.13s
turn 2 · NVIDIA-Nemotron-3-Nano-30B-A3B · 3915 in / 159 out · 2.07s · $0.00027

The condition `if not (not isinstance(other, Mapping))` is equivalent to `if isinstance(other, Mapping)`, which incorrectly returns NotImplemented when other is a Mapping. This causes the method to proceed and attempt to call `.items()` on non-Mapping objects like CustomOr, leading to the AttributeError. The correct logic should return NotImplemented when other is NOT a Mapping, so the condition should be simplified to `if not isinstance(other, Mapping)`.

--- a/src/sortedcontainers/sorteddict.py+++ b/src/sortedcontainers/sorteddict.py@@ -284,5 +284,5 @@      def __ror__(self, other):-        if not (not isinstance(other, Mapping)):+        if not isinstance(other, Mapping):             return NotImplemented         items = chain(other.items(), self.items())

tests: all tests pass 299 passed

Final patch

--- a/src/sortedcontainers/sorteddict.py+++ b/src/sortedcontainers/sorteddict.py@@ -284,5 +284,5 @@      def __ror__(self, other):-        if not (not isinstance(other, Mapping)):+        if not isinstance(other, Mapping):             return NotImplemented         items = chain(other.items(), self.items())