Skip to content

tempfile.gettempdir() documentation is inaccurate for Windows #151138

@Jackenmen

Description

@Jackenmen

Documentation

This part of the documentation is inaccurate:

  1. A platform-specific location:
    • On Windows, the directories C:\TEMP, C:\TMP, \TEMP, and \TMP, in that order

As you can see from the implementation, %USERPROFILE%\AppData\Local\Temp and %SYSTEMROOT%\Temp are checked before the rest of the already documented directories:

cpython/Lib/tempfile.py

Lines 169 to 174 in 3ece6b5

if _os.name == 'nt':
dirlist.extend([ _os.path.expanduser(r'~\AppData\Local\Temp'),
_os.path.expandvars(r'%SYSTEMROOT%\Temp'),
r'c:\temp', r'c:\tmp', r'\temp', r'\tmp' ])
else:
dirlist.extend([ '/tmp', '/var/tmp', '/usr/tmp' ])

This has been the behaviour since Python 3.6, as introduced by:
e5f41d2

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    Status
    No status
    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions