Oh no mkstemp is already obsolete (in Linux), now we have O_TMPFILE [1] for creating temporary files that do not even have names...
(and of course though there is a slight race you can unlink the file you get through mkstemp while keeping it open, that seems to be the strategy used by python's tempfile.TemporaryFile)
There is still a possibility that an attacker opens the file before you unlink it and starts writing to it, which O_TMPFILE gets rid of as it never has a name so can never be opened.
1. Create temporary file in the same directory as the target path.
2. Write and fsync the temporary file
3. Rename the temporary file to the target filename
Oh, and on Linux you can open even deleted files by using /proc/<N>/fd/<M>. It may look like a symlink, but it's not.