MutaFix run: toolz-007
ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory
- if not (key in d2): (injected bug)+ if key in d2: (original)retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore no
Trace
failing tests and errors
toolz/tests/test_dicttoolz.py::TestDict::test_dissoc toolz/tests/test_dicttoolz.py::TestDefaultDict::test_dissoc toolz/tests/test_dicttoolz.py::TestCustomMapping::test_dissoc toolz/tests/test_dicttoolz.py::test_dissoc_agrees_on_both_sides_of_its_size_heuristictoolz/tests/test_dicttoolz.py::TestDict::test_dissoc
E AssertionError: assert {'a': 1, 'b': 2} == {'b': 2}
E
E Omitting 1 identical items, use -vv to show
E Left contains 1 more item:
E {'a': 1}
E Use -v to get more difftoolz/tests/test_dicttoolz.py::TestDefaultDict::test_dissocE AssertionError: assert {'a': 1, 'b': 2} == {'b': 2}
E
E Omitting 1 identical items, use -vv to show
E Left contains 1 more item:
E {'a': 1}
E Use -v to get more difftoolz/tests/test_dicttoolz.py::TestDict::test_dissoc in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.candidates in retriever order
toolz/dicttoolz.py::dissoctoolz/dicttoolz.py::_get_factorytoolz/functoolz.py::Compose.__name__toolz/functoolz.py::excepts.__name__toolz/itertoolz.py::difftoolz/functoolz.py::_check_sigspectoolz/dicttoolz.py::itemfiltertoolz/itertoolz.py::jointoolz/dicttoolz.py::get_intoolz/itertoolz.py::plucktoolz/dicttoolz.py::merge_withtoolz/functoolz.py::memoizetoolz/_signatures.py::check_validtoolz/itertoolz.py::gettoolz/itertoolz.py::concattoolz/__init__.py::__getattr__toolz/functoolz.py::compose_lefttoolz/curried/exceptions.py::mergetoolz/curried/exceptions.py::merge_withtoolz/itertoolz.py::partition_all
toolz/dicttoolz.py::dissoctoolz/dicttoolz.py::_get_factorytoolz/functoolz.py::Compose.__name__toolz/functoolz.py::excepts.__name__toolz/itertoolz.py::diff
read toolz/dicttoolz.py::dissoc
The failing tests are all related to the `test_dissoc` method in the dicttoolz module, and the only function directly involved in those failures is `dissoc` in toolz/dicttoolz.py. The error messages show that the result of `dissoc` is missing an item that should be present, indicating a logic error in how keys are removed or how the new dictionary is constructed. The `_get_factory` function is a helper and does not directly affect the correctness of the `dissoc` behavior, and the other candidates are unrelated to dict dissocation.
The current logic incorrectly adds all items from the original dictionary to the new dictionary (d2.update(d)) and then attempts to delete keys only if they are not present in d2, which leads to the wrong items being retained. The failing tests expect that only the specified keys are removed, and no extra items are left behind. The patch removes the problematic update logic and directly deletes each key from d2 if it exists, which correctly implements the intended behavior of removing only the specified keys without affecting other items.
--- a/toolz/dicttoolz.py+++ b/toolz/dicttoolz.py@@ -215,9 +215,7 @@ d2 = factory() - if len(keys) < len(d) * .6:- d2.update(d)- for key in keys:- if not (key in d2):- del d2[key]+ for key in keys:+ if key in d2:+ del d2[key] else: remaining = set(d)
tests: all tests pass
Final patch
--- a/toolz/dicttoolz.py+++ b/toolz/dicttoolz.py@@ -215,9 +215,7 @@ d2 = factory() - if len(keys) < len(d) * .6:- d2.update(d)- for key in keys:- if not (key in d2):- del d2[key]+ for key in keys:+ if key in d2:+ del d2[key] else: remaining = set(d)