New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-30400: Fix race condition in shutil.copyfile() #1659
base: main
Are you sure you want to change the base?
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
596517a
to
5047f42
Compare
Hum. I'm not sure that the approach is reliable. Why not using os.fstat() on the open src and dst files?
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again As discussed on the bug tracker, this PR now opens the source and destination early and uses file descriptors in order to avoid a race condition where the file being copied is replaced at some point during copyfile's execution. I've just added a missing test so the modifications should have good test coverage. Thanks, |
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
@pkmoore, please resolve the merge conflicts. Thanks! |
@pkmoore please resolve the merge conflicts. Thanks! |
This PR is stale because it has been open for 30 days with no activity. |
This PR is currently not passing all tests. I believe this is caused by the mock file objects not operating correctly with os.stat() and os.fstat().
https://bugs.python.org/issue30400