Skip to content

gh-95484: Improve tempfile docs for conditions when files are removed - #95485

Merged
encukou merged 4 commits into
python:mainfrom
NickCrews:tempfile-docs
Dec 3, 2026
Merged

encukou merged 4 commits into
python:mainfrom
NickCrews:tempfile-docs

Conversation

@NickCrews

@NickCrews NickCrews commented Jul 30, 2022 •

Copy link
Copy Markdown
Contributor

Lightly edit some prose. On my initial read of the docs, I was confused about when tempfiles are deleted. I think this PR would have helped me.

Now there are two paragraphs, the first one has to do with "creating a tempfile" and the second is "deleting a tempfile". I think this is a better way of organizing things than what it used to be.

Before, an entire paragraph was about "using as a context manager", which I think is less important than "when is a tempfile deleted". The first paragraph was "what happens when you make a tempfile and also here is one way of when it is closed"

@bedevere-bot bedevere-bot added awaiting review docs Documentation in the Doc dir skip news labels Jul 30, 2022
@NickCrews

Copy link
Copy Markdown
Contributor Author

The bullet list doesn't render properly, I'm actually cloning locally to debug, will push a fix soon...

@NickCrews
NickCrews force-pushed the tempfile-docs branch 3 times, most recently from a24a9da to 84d5ce7 Compare July 31, 2022 00:22
@NickCrews

Copy link
Copy Markdown
Contributor Author

OK, rendering is fixed, it now looks like
image

Comment thread Doc/library/tempfile.rst Outdated
:ref:`tempfile-examples`). On completion of the context or
destruction of the file object the temporary file will be removed
from the filesystem.
The temporary file will be removed from the filesystem when the returned

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This sentence is not quite grammatical. I'd suggest starting with "The temporary file will be removed from the file system under the following conditions:"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I addressed this in eb61e19. See what you think of that.

@ryan-duve

Copy link
Copy Markdown
Contributor

Hey @NickCrews -- Are you still interested in pushing this forward? If so, there's an outstanding suggestion to you from Jelle.

@github-actions

Copy link
Copy Markdown

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 Apr 11, 2026
@NickCrews

Copy link
Copy Markdown
Contributor Author

@ryan-duve Thanks for the nudge, I had totally forgotten about this PR :)

Just pushed a new version that addresses that feedback, let me know what you think.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 11, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 12, 2026
@NickCrews

Copy link
Copy Markdown
Contributor Author

@JelleZijlstra I think I addressed your feedback here, if you have a few minutes for a re review. Thanks!

@sirosen sirosen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I disagree with the decision to nest the fact that the TemporaryFile can be used as a context manager under details about cleanup and file deletion. Being a context manager is a first-class characteristic of an object, and determines whether or not it can be used with a unique syntactic form (the with statement).

I'm also not convinced that a bulleted list is the best way to present this information.
I've included a suggested rewrite (sorry it's the whole block of text! there's really only one conceptual change, but it touches the beginning and end), to move mention of being a context manager to the start. That intrinsically frees us up to make the cleanup details simpler.

Comment thread Doc/library/tempfile.rst Resolved
@sirosen sirosen removed the stale Stale PR or inactive for long period of time. label Aug 14, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Nov 13, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
📖 66 files changed · 1 added · 65 modified

Preview · build overview · cpython-previews · built Dec. 2, 2026, 10:28 p.m. UTC

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Nov 18, 2026
Comment thread Doc/library/tempfile.rst Resolved
Comment thread Doc/library/tempfile.rst Resolved
Co-authored-by: Petr Viktorin <encukou@gmail.com>

@sirosen sirosen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@encukou, because the original author has stepped back from this PR, and I like/agree with the changes you suggested, I've applied them.

Comment thread Doc/library/tempfile.rst Resolved
@encukou
encukou merged commit b40f5b9 into python:main Dec 3, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Dec 3, 2026
@encukou encukou added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Dec 3, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @NickCrews for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Thanks @NickCrews for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Dec 3, 2026

Copy link
Copy Markdown

GH-163075 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Dec 3, 2026
@bedevere-app

bedevere-app Bot commented Dec 3, 2026

Copy link
Copy Markdown

GH-163076 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Dec 3, 2026
encukou added a commit that referenced this pull request Dec 3, 2026
…e removed (GH-95485) (GH-163075)

(cherry picked from commit b40f5b9)

Co-authored-by: Nick Crews <nicholas.b.crews@gmail.com>
Co-authored-by: Stephen Rosen <sirosen@globus.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
encukou added a commit that referenced this pull request Dec 3, 2026
…e removed (GH-95485) (GH-163076)

(cherry picked from commit b40f5b9)

Co-authored-by: Nick Crews <nicholas.b.crews@gmail.com>
Co-authored-by: Stephen Rosen <sirosen@globus.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
@NickCrews

Copy link
Copy Markdown
Contributor Author

The version that landed looks great to me. Thank you to everyone for your suggestions and for taking this over!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants