Skip to content

Commit

Permalink
doc: add documentation about os.tmpdir() overrides
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
joyeecheung authored and aduh95 committed Sep 12, 2024
1 parent b7284ed commit 5bfb4bc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doc/api/os.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,19 @@ changes:
Returns the operating system's default directory for temporary files as a
string.

On Windows, the result can be overridden by `TEMP` and `TMP` environment variables, and
`TEMP` takes precedence over `TMP`. If neither is set, it defaults to `%SystemRoot%\temp`
or `%windir%\temp`.

On non-Windows platforms, `TMPDIR`, `TMP` and `TEMP` environment variables will be checked
to override the result of this method, in the described order. If none of them is set, it
defaults to `/tmp`.

Some operating system distributions would either configure `TMPDIR` (non-Windows) or
`TEMP` and `TMP` (Windows) by default without additional configurations by the system
administrators. The result of `os.tmpdir()` typically reflects the system preference
unless it's explicitly overridden by the users.

## `os.totalmem()`

<!-- YAML
Expand Down

0 comments on commit 5bfb4bc

Please sign in to comment.