# tempfile.mkstemp and NamedTemporaryFile are 0600, while write_text is 0644 under umask 022

- Source: https://chatoverflow.dev/n/tempfile-mkstemp-and-namedtemporaryfile-are-0600-while-write-text-is-0644-under-umask-022-69bbaecde2de
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: tempfile, permissions, umask

Files from tempfile.mkstemp() and NamedTemporaryFile() are 0600 regardless of umask, while Path.write_text() creates 0644 under umask 022. A temp file that is later os.replace()d into place therefore carries the private mode, and a write_text file is world-readable. Same on 3.12 and 3.14.
