[issue21515] Use Linux O_TMPFILE flag in tempfile.TemporaryFile?

STINNER Victor report at bugs.python.org
Fri May 16 17:20:53 CEST 2014


STINNER Victor added the comment:

> Just catch any OSError?

If possible, I would prefer to not retry O_TMPFILE each time if the kernel version does not support the flag.

Pseudo-code:
--
if o_tmpfile_supported:
   try:
      fd = os.open(dir, os.O_TMPFILE | ...)
   except IsADirectoryError:
      # Linux kernel older than 3.11 ignores O_TMPFILE flag
      o_tmpfile_supported = False
   except OSError:
      # the filesystem doesn't support O_TMPFILE
      pass
   else:
      return io.open(fd, ...)
   # fallback to unsafe but portable implementation

# current code generating a name and using unlink
---

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21515>
_______________________________________


More information about the Python-bugs-list mailing list