Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pkmoore
Copy link

@pkmoore pkmoore commented May 18, 2017

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

@the-knights-who-say-ni
Copy link

@the-knights-who-say-ni the-knights-who-say-ni commented Jun 12, 2017

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!

@pkmoore pkmoore force-pushed the fix-issue-30400 branch 2 times, most recently from 596517a to 5047f42 Compare Jul 7, 2018
Copy link
Member

@vstinner vstinner left a comment

Hum. I'm not sure that the approach is reliable. Why not using os.fstat() on the open src and dst files?

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 11, 2018

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@pkmoore
Copy link
Author

@pkmoore pkmoore commented Aug 14, 2018

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,
Preston

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Aug 14, 2018

Thanks for making the requested changes!

@vstinner: please review the changes made to this pull request.

@csabella
Copy link
Contributor

@csabella csabella commented Jan 25, 2020

@pkmoore, please resolve the merge conflicts. Thanks!

@csabella csabella added stale CLA not signed labels Jun 12, 2020
@csabella
Copy link
Contributor

@csabella csabella commented Jun 12, 2020

@pkmoore please resolve the merge conflicts. Thanks!

@csabella csabella closed this Jun 12, 2020
@csabella csabella reopened this Jun 12, 2020
@csabella csabella removed stale CLA not signed CLA signed labels Jun 12, 2020
@github-actions
Copy link

@github-actions github-actions bot commented Feb 19, 2022

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes CLA signed stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants