Skip to content

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

Closed
wants to merge 1 commit into 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

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 July 7, 2018 13:45
Copy link
Member

@vstinner vstinner left a 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?

@bedevere-bot
Copy link

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

Thanks for making the requested changes!

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

@csabella
Copy link
Contributor

@pkmoore, please resolve the merge conflicts. Thanks!

@csabella csabella added stale Stale PR or inactive for long period of time. CLA not signed labels Jun 12, 2020
@csabella
Copy link
Contributor

@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 Stale PR or inactive for long period of time. CLA not signed labels Jun 12, 2020
@github-actions
Copy link

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

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 19, 2022
@erlend-aasland
Copy link
Contributor

Closing this PR as the concerns have not been addressed, and the PR has been stale for years.

@abadger
Copy link
Contributor

abadger commented Jul 19, 2025

@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.

@abadger
Copy link
Contributor

abadger commented Jul 19, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy