-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-30400: Fix race condition in shutil.copyfile() #1659
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
9684ebf
to
7948379
Compare
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. |
Closing this PR as the concerns have not been addressed, and the PR has been stale for years. |
@pkmoore are you still interested in this? I would be willing to pick it up and care for it until someone merges it but if I want to credit you and use your code as a basis, you wuold need to sign the CLA. If you're not interested, I will reimplement it from the discussion here and in the issue. |
@pkmoore ah, I found that you have signed the cla in the past by looking at bugs.python.org. I can continue your work in a new PR but let me know if you want to take it over. |
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