MutaFix run: boltons-007
ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory
- if not (fn_ext): (injected bug)+ if fn_ext: (original)retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore no
Trace
failing tests and errors
tests/test_fileutils.py::test_rotate_file_one_rotation tests/test_fileutils.py::test_rotate_file_full_rotationtests/test_fileutils.py::test_rotate_file_one_rotation
E AssertionError: assert False
E + where False = exists()
E + where exists = (WindowsPath('~/AppData/Local/Temp/pytest-of-user/pytest-336/test_rotate_file_one_rotation0') / 'test_file.1.txt').existstests/test_fileutils.py::test_rotate_file_full_rotationE AssertionError: assert 'test content 1' == 'test content 0' E E - test content 0 E ? ^ E + test content 1 E ? ^
tests/test_fileutils.py::test_rotate_file_one_rotation in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.candidates in retriever order
boltons/fileutils.py::rotate_fileboltons/urlutils.py::URL.pathboltons/urlutils.py::URL.pathboltons/dictutils.py::ManyToMany.removeboltons/setutils.py::IndexedSet.removeboltons/queueutils.py::BasePriorityQueue.removeboltons/listutils.py::BarrelList.appendboltons/setutils.py::_ComplementSet.removeboltons/urlutils.py::quote_path_partboltons/dictutils.py::ManyToMany.addboltons/dictutils.py::OrderedMultiDict.popboltons/urlutils.py::OrderedMultiDict.popboltons/queueutils.py::BasePriorityQueue.popboltons/setutils.py::_ComplementSet.popboltons/urlutils.py::to_unicodeboltons/dictutils.py::OneToOne.popboltons/cacheutils.py::LRI.popboltons/queueutils.py::BasePriorityQueue._cullboltons/cacheutils.py::ThresholdCounter.addboltons/listutils.py::BarrelList.pop
boltons/fileutils.py::rotate_fileboltons/urlutils.py::URL.pathboltons/urlutils.py::URL.pathboltons/dictutils.py::ManyToMany.removeboltons/setutils.py::IndexedSet.remove
read boltons/fileutils.py::rotate_file
The failing tests involve file rotation, and candidate 1 is the only function in the list that directly handles file rotation (rotate_file). The error messages indicate issues with file existence and content after rotation, which points to a bug in the rotate_file implementation.
The bug is in the logic that appends the extension when generating kept_names. When fn_ext is empty (i.e., the filename has no extension), the code incorrectly appends the extension (which is empty) after the number, but when fn_ext is not empty, it should still include the extension in the filename. The current condition uses `if not (fn_ext)` which is truthy when fn_ext is an empty string, but the logic for appending the extension is reversed. The fix ensures that the extension is always included in the generated filename, regardless of whether it exists.
--- a/boltons/fileutils.py+++ b/boltons/fileutils.py@@ -712,8 +712,8 @@ kept_names = [] for i in range(1, keep + 1):- if not (fn_ext):+ if not fn_ext: kept_names.append(f'{fn_root}.{i}{fn_ext}') else:- kept_names.append(f'{fn_root}.{i}')+ kept_names.append(f'{fn_root}.{i}{fn_ext}') fns = [filename] + kept_names
tests: all tests pass
Final patch
--- a/boltons/fileutils.py+++ b/boltons/fileutils.py@@ -712,8 +712,8 @@ kept_names = [] for i in range(1, keep + 1):- if not (fn_ext):+ if not fn_ext: kept_names.append(f'{fn_root}.{i}{fn_ext}') else:- kept_names.append(f'{fn_root}.{i}')+ kept_names.append(f'{fn_root}.{i}{fn_ext}') fns = [filename] + kept_names