Skip to content

gh-151138: Document Windows-specific temp dirs in gettempdir() - #156016

Closed
maksimtech wants to merge 3 commits into
python:mainfrom
maksimtech:fix/tempfile-windows-docs
Closed

gh-151138: Document Windows-specific temp dirs in gettempdir()#156016
maksimtech wants to merge 3 commits into
python:mainfrom
maksimtech:fix/tempfile-windows-docs

Conversation

@maksimtech

Copy link
Copy Markdown

Problem

The tempfile.gettempdir() documentation incorrectly states that on Windows,
only C:\TEMP, C:\TMP, \TEMP, and \TMP are checked.

Fix

Since Python 3.6 (commit e5f41d2), the implementation also checks:

  • %USERPROFILE%\AppData\Local\Temp
  • %SYSTEMROOT%\Temp

These are checked before the hardcoded paths but were missing from the docs.

This PR:

  • Adds the two missing directories to the documented search order
  • Adds a versionchanged:: 3.6 note to document when this was introduced

Testing

Documentation-only change. Verified with make html — build succeeded with no errors.

Fixes gh-151138

@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Aug 18, 2026
@python-cla-bot

python-cla-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Add %USERPROFILE%\AppData\Local\Temp and %SYSTEMROOT%\Temp to
the documented Windows directory search order for gettempdir().

These directories have been checked since Python 3.6 (commit e5f41d2)
but were missing from the documentation. Also add a versionchanged
note for 3.6 to indicate when this behavior was introduced.
@maksimtech
maksimtech force-pushed the fix/tempfile-windows-docs branch from 43e99fd to 18f1503 Compare August 18, 2026 13:31
@read-the-docs-community

read-the-docs-community Bot commented Aug 18, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34121839 | 📁 Comparing 9eebcbb against main (05ab13e)

  🔍 Preview build  

2 files changed
± library/tempfile.html
± whatsnew/changelog.html

@aisk

aisk commented Aug 18, 2026

Copy link
Copy Markdown
Member

Hi @maksimtech, thanks for your contribution. However, there's already an active PR for this issue: #151210.

In the future, please check for existing PRs before opening a new one.

@aisk aisk closed this Aug 18, 2026
@maksimtech

Copy link
Copy Markdown
Author

Thanks for the heads up and for closing it! I checked the linked PRs
but didn't realize #151210 was still actively being worked on.

I'll follow that PR and help if I can.

@maksimtech
maksimtech deleted the fix/tempfile-windows-docs branch August 18, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

tempfile.gettempdir() documentation is inaccurate for Windows

2 participants