[issue14243] tempfile.NamedTemporaryFile not particularly useful on Windows

Richard Oudkerk report at bugs.python.org
Tue Mar 12 23:49:11 CET 2013


Richard Oudkerk added the comment:

Sorry, I was not very clear.

If you use the O_TEMPORARY flag with open() to get a file handle, then the share mode used with the underlying CreateFile() function is 

    X = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE

whereas, if you don't use O_TEMPORARY then the share mode is

    Y = FILE_SHARE_READ | FILE_SHARE_WRITE

While a handle is open with share mode X, you can only reopen the file if you also use share mode X.  Therefore (using the msvcrt) you can only reopen it using O_TEMPORARY.*


* sopen() does give some extra control over the share mode, but you still can't use it to get share mode X without also using O_TEMPORARY.

----------

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


More information about the Python-bugs-list mailing list