David Lukeš added the comment:
> You can use TemporaryDirectory.
That was actually the first approach I tried :) I even thought this could be
used to make `mktemp` safe -- just create the name in a `TemporaryDirectory`.
However, after reading through the mailing list thread, I realized this
Serhiy Storchaka added the comment:
You can use TemporaryDirectory.
with tempfile.TemporaryDirectory() as dir:
fifo_path = os.path.join(dir, "fifo")
os.mkfifo(fifo_path, 0o600)
...
--
nosy: +serhiy.storchaka
___
Python tracker
David Lukeš added the comment:
> A secure `mktemp` could be as simple as ...
Though in practice, I'd rather be inclined to make the change in
`tempfile._RandomNameSequence`, so as to get the same behavior across the
entire module, instead of special-casing `mktemp`. As Guido van Rossum
New submission from David Lukeš :
I recently came across a non-testing use case for `tempfile.mktemp()` where I
struggle to find a viable alternative -- temporary named pipes (FIFOs):
```
import os
import tempfile
import subprocess as sp
fifo_path = tempfile.mktemp()
os.mkfifo(fifo_path,