diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-10-20 22:15:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-10-20 22:15:08 (GMT) |
commit | 9aba8c8a9552ae74b30b261b2eaa9a5720a2c27f (patch) | |
tree | 074dce9409a7c673c3d8f54eb7e5ca853c9bc10f /Lib/tempfile.py | |
parent | d17427b7bd69644bbbd3ccb97dcb920ac50197a6 (diff) | |
download | cpython-9aba8c8a9552ae74b30b261b2eaa9a5720a2c27f.zip cpython-9aba8c8a9552ae74b30b261b2eaa9a5720a2c27f.tar.gz cpython-9aba8c8a9552ae74b30b261b2eaa9a5720a2c27f.tar.bz2 |
Issue #21515: Elaborate tempfile.TemporaryFile() comment
Explain why calling os.open() with os.O_TMPFILE is a safe test to check if
O_TMPFILE is supported by the running kernel.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r-- | Lib/tempfile.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 2f1f9fd..e87eb09 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -591,12 +591,20 @@ else: flags2 = (flags | _os.O_TMPFILE) & ~_os.O_CREAT fd = _os.open(dir, flags2, 0o600) except IsADirectoryError: - # Linux kernel older than 3.11 ignores O_TMPFILE flag. - # Set flag to False to not try again. + # Linux kernel older than 3.11 ignores the O_TMPFILE flag: + # O_TMPFILE is read as O_DIRECTORY. Trying to open a directory + # with O_RDWR|O_DIRECTORY fails with IsADirectoryError, a + # directory cannot be open to write. Set flag to False to not + # try again. _O_TMPFILE_WORKS = False except OSError: # The filesystem of the directory does not support O_TMPFILE. # For example, OSError(95, 'Operation not supported'). + # + # On Linux kernel older than 3.11, trying to open a regular + # file (or a symbolic link to a regular file) with O_TMPFILE + # fails with NotADirectoryError, because O_TMPFILE is read as + # O_DIRECTORY. pass else: try: |