Repository navigation
Prevent Windows directory replacement from deleting destination files - #825
Open
Shubham-Padkonde wants to merge 1 commit into
Open
Shubham-Padkonde wants to merge 1 commit into
Shubham-Padkonde wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #816.
On Windows,
os.replace(directory, existing_file)succeeds and destroys the file's contents._OsPathBackend.replace()now rejects this case withNotADirectoryError, matching the existing backend contract.Check
os.lstat()'sFILE_ATTRIBUTE_DIRECTORYon Windows when the destination entry exists. This also covers directory junctions and directory symlinks, including dangling links, without following the source. POSIX behavior remains delegated toos.replace, so replacing a file with a directory symlink continues to work. Directory moves to unused paths and ordinary file replacement are preserved.Add a focused local-backend test module that can collect on Windows without the POSIX-only imports in
backend_test.py(covered separately by #819).Validation:
lstatresults.test_use_backendassumes TensorFlow is installed; the same failure reproduces on the base revision without TensorFlow.git diff --checkpasses. Unrelated formatting changes were discarded.OpenAI Codex (GPT-6) assisted with investigation, implementation, tests, and review of the diff. No human review is claimed.