Skip to content

gh-151138: Correct documented tempfile Windows temp directory search order - #155029

Draft
Diwak4r wants to merge 1 commit into
python:mainfrom
Diwak4r:fix/tempfile-docs-windows-search
Draft

gh-151138: Correct documented tempfile Windows temp directory search order#155029
Diwak4r wants to merge 1 commit into
python:mainfrom
Diwak4r:fix/tempfile-docs-windows-search

Conversation

@Diwak4r

@Diwak4r Diwak4r commented Aug 1, 2026

Copy link
Copy Markdown

Problem

The tempfile.gettempdir() docs incorrectly document the Windows temp directory search order.

Current docs claim:

C:\TEMP, C:\TMP, \TEMP, \TMP

Actual implementation (Lib/tempfile.py lines 192-194):

for envname in 'TMPDIR', 'TEMP', 'TMP':
    dirname = os.getenv(envname)
    if dirname: return dirname

On Windows, TEMP and TMP env vars point to %USERPROFILE%\AppData\Local\Temp (user temp) and %SYSTEMROOT%\Temp (system temp), not the hardcoded paths the docs claim.

Fixes #151138.

Fix

Update Doc/library/tempfile.rst to document the correct search order:

{USERPROFILE}\AppData\Local\Temp
{SYSTEMROOT}\Temp
c:	emp, c:	mp, 	emp, 	mp

This reflects actual runtime behavior: environment variables first, then hardcoded fallback paths.

Test

Documentation-only change. Verified docs build with make html.

The existing docs claim gettempdir() searches C:\TEMP, C:\TMP, \TEMP, \TMP
on Windows, but the actual implementation (Lib/tempfile.py lines 192-194)
first checks TMPDIR, TEMP, and TMP environment variables.

On Windows, TEMP and TMP typically point to:
- %USERPROFILE%\AppData\Local\Temp (user temp)
- %SYSTEMROOT%\Temp (system temp)

Update the docs to reflect the actual search order: env vars first, then
hardcoded fallback paths.

Fixes python#151138
Copilot AI review requested due to automatic review settings August 1, 2026 13:27
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Aug 1, 2026
@python-cla-bot

python-cla-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33866842 | 📁 Comparing 73d28d5 against main (534b6b0)

  🔍 Preview build  

1 file changed
± library/tempfile.html

@StanFromIreland StanFromIreland changed the title docs(tempfile): correct Windows temp directory search order gh-151138: Correct documented tempfile Windows temp directory search order Aug 1, 2026
@StanFromIreland
StanFromIreland marked this pull request as draft August 1, 2026 18:23
@StanFromIreland

Copy link
Copy Markdown
Member

You'll have to sign the CLA before we can review.

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 issue skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

tempfile.gettempdir() documentation is inaccurate for Windows

4 participants