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

STINNER Victor report at bugs.python.org
Fri May 16 15:08:03 CEST 2014


STINNER Victor added the comment:

It looks like open() ignores O_TMPFILE (0o20000000) on old Linux kernels. Test on Linux 3.2:

>>> fd=os.open("/tmp", os.O_RDWR | O_TMPFILE, 0o600)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 21] Is a directory: '/tmp'

>>> fd=os.open("/tmp", os.O_RDWR | os.O_DIRECTORY, 0o600)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 21] Is a directory: '/tmp'

So we should catch OSError(21, "Is a directory: '/tmp'") and fallback to the current implementation (random name, unlink), and remember that the kernel version is too old.

----------

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


More information about the Python-bugs-list mailing list