[issue26362] Approved API for creating a temporary file path

Ben Finney report at bugs.python.org
Mon May 1 08:27:48 EDT 2017


Ben Finney added the comment:

On 01-May-2017, R. David Murray wrote:
> You are depending on a non-portable feature of os.rename there

What's the non-portable dependency?

If you mean the expectation that ‘os.rename’ will be atomic on
success: the documentation promises “If successful, the renaming will
be an atomic operation”, without any non-compatibility caveat
<URL:https://docs.python.org/3/library/os.html#os.rename>.

If you mean the ‘except OSError’ clause: that's not a dependency of
this example. It is handling a case that is documented to occur on
some platforms. On platforms that don't have that behaviour, the
clause is not a dependency of this use case.

Neither of those is germane to the use case being demonstrated: the
need for a temporary filesystem path as generated by ‘tempfile.mktemp’.

> so I'm not convinced this makes a good use case for the Python
> stdlib.

Note that Tim Chase is *not* presenting a use case for ‘os.rename’,
but rather a use case for ‘tempfile.mktemp’. For that purpose it seems
a valid use case.

----------

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


More information about the Python-bugs-list mailing list