Skip to content

Commit 18f1503

Browse files
committed
gh-151138: Document Windows-specific temp dirs in gettempdir()
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.
1 parent 05ab13e commit 18f1503

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Doc/library/tempfile.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,14 @@ The module defines the following user-callable items:
348348

349349
#. A platform-specific location:
350350

351-
* On Windows, the directories :file:`C:\\TEMP`, :file:`C:\\TMP`,
352-
:file:`\\TEMP`, and :file:`\\TMP`, in that order.
351+
* On Windows, the following directories, in that order:
352+
353+
- :file:`%USERPROFILE%\\AppData\\Local\\Temp`
354+
- :file:`%SYSTEMROOT%\\Temp`
355+
- :file:`C:\\TEMP`
356+
- :file:`C:\\TMP`
357+
- :file:`\\TEMP`
358+
- :file:`\\TMP`
353359

354360
* On all other platforms, the directories :file:`/tmp`, :file:`/var/tmp`, and
355361
:file:`/usr/tmp`, in that order.
@@ -359,6 +365,11 @@ The module defines the following user-callable items:
359365
The result of this search is cached, see the description of
360366
:data:`tempdir` below.
361367

368+
.. versionchanged:: 3.6
369+
On Windows, :file:`%USERPROFILE%\\AppData\\Local\\Temp` and
370+
:file:`%SYSTEMROOT%\\Temp` are now checked before the hardcoded
371+
directory paths.
372+
362373
.. versionchanged:: 3.10
363374

364375
Always returns a str. Previously it would return any :data:`tempdir`

0 commit comments

Comments
 (0)