Skip to content

Commit 7c83c15

Browse files
joyeecheungtargos
authored andcommittedOct 2, 2024
doc: add documentation about os.tmpdir() overrides
This documents the TMPDIR, TEMP and TMP overrides on different platforms and that some operating systems set these by default. PR-URL: #54613 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 71ca266 commit 7c83c15

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎doc/api/os.md

+13
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,19 @@ changes:
416416
Returns the operating system's default directory for temporary files as a
417417
string.
418418

419+
On Windows, the result can be overridden by `TEMP` and `TMP` environment variables, and
420+
`TEMP` takes precedence over `TMP`. If neither is set, it defaults to `%SystemRoot%\temp`
421+
or `%windir%\temp`.
422+
423+
On non-Windows platforms, `TMPDIR`, `TMP` and `TEMP` environment variables will be checked
424+
to override the result of this method, in the described order. If none of them is set, it
425+
defaults to `/tmp`.
426+
427+
Some operating system distributions would either configure `TMPDIR` (non-Windows) or
428+
`TEMP` and `TMP` (Windows) by default without additional configurations by the system
429+
administrators. The result of `os.tmpdir()` typically reflects the system preference
430+
unless it's explicitly overridden by the users.
431+
419432
## `os.totalmem()`
420433

421434
<!-- YAML

0 commit comments

Comments
 (0)
Please sign in to comment.