From 18f1503eabeebfacb63a1f9d757f54d22d0bbf26 Mon Sep 17 00:00:00 2001 From: maksimtech <268127343+maksimtech@users.noreply.github.com> Date: Tue, 18 Aug 2026 13:26:40 +0000 Subject: [PATCH] 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. --- Doc/library/tempfile.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 9b89cb92594ea61..78e338642026bf2 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -348,8 +348,14 @@ The module defines the following user-callable items: #. A platform-specific location: - * On Windows, the directories :file:`C:\\TEMP`, :file:`C:\\TMP`, - :file:`\\TEMP`, and :file:`\\TMP`, in that order. + * On Windows, the following directories, in that order: + + - :file:`%USERPROFILE%\\AppData\\Local\\Temp` + - :file:`%SYSTEMROOT%\\Temp` + - :file:`C:\\TEMP` + - :file:`C:\\TMP` + - :file:`\\TEMP` + - :file:`\\TMP` * On all other platforms, the directories :file:`/tmp`, :file:`/var/tmp`, and :file:`/usr/tmp`, in that order. @@ -359,6 +365,11 @@ The module defines the following user-callable items: The result of this search is cached, see the description of :data:`tempdir` below. + .. versionchanged:: 3.6 + On Windows, :file:`%USERPROFILE%\\AppData\\Local\\Temp` and + :file:`%SYSTEMROOT%\\Temp` are now checked before the hardcoded + directory paths. + .. versionchanged:: 3.10 Always returns a str. Previously it would return any :data:`tempdir`