Skip to content

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

Open
NickCrews wants to merge 3 commits into
python:mainfrom
NickCrews:tempfile-docs
Open

NickCrews wants to merge 3 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

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35942744 | 📁 Comparing db8ab2d against main (910a92b)

  🔍 Preview build  

1 file changed
± library/tempfile.html

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 skip news stale Stale PR or inactive for long period of time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

5 participants