Skip to content

gh-135648: Document that shutil.copyfileobj doesn't flush #135737

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

freakboy3742
Copy link
Contributor

@freakboy3742 freakboy3742 commented Jun 20, 2025

Document that shutil.copyfileobj() doesn't flush the destination stream on completion, so file content may not be reliably available.

Modifies the Emscripten build script to avoid the problem that the documentation is warning about.


📚 Documentation preview 📚: https://cpython-previews--135737.org.readthedocs.build/

Comment on lines +1 to +2
The documentation for :func:`shutil.copyfileobj` now warns the user of the
need to close or flush the destination stream on completion.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Documentation blurb section is usually used for meta changes, e.g. tags or theme, and not entries about changes in the docs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that a NEWS entry is needed.

with urlopen(
"https://github.com/libffi/libffi/releases/download/v3.4.6/libffi-3.4.6.tar.gz"
) as response:
shutil.copyfileobj(response, tmp_file)
tmp_file.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do tmp_file.flush() and remove delete_on_close=False?

@hoodmane
Copy link
Contributor

Thanks @freakboy3742!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review docs Documentation in the Doc dir needs backport to 3.14 bugs and security fixes
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants