tempname.mktemp functionality deprecation

Ben Finney ben+python at benfinney.id.au
Sun Apr 30 19:15:04 EDT 2017

Tim Chase <python.list at tim.thechases.com> writes:

> Unfortunately, tempfile.mktemp() is described as deprecated since 2.3
> (though appears to still exist in the 3.4.2 that is the default Py3 on
> Debian Stable). While the deprecation notice says "In version 2.3 of
> Python, this module was overhauled for enhanced security. It now
> provides three new functions, NamedTemporaryFile(), mkstemp(), and
> mkdtemp(), which should eliminate all remaining need to use the
> insecure mktemp() function", as best I can tell, all of the other
> functions/objects in the tempfile module return a file object, not a
> string suitable for passing to link().

The problem you describe is that ‘tmpfile.mktemp’ is deprecated, but
there is no other supported standard-library API which does its job.

I reported this – for a different use case – in issue26362 [0]

The suggested solutions in the documentation do not address the use case
described there; and they do not address the use case you've described
here either.

Would you be kind enough to update that issue with a description of your
use case as well?

[0] The issue currently has a message from me, over a year ago, saying
    that I will “work on a patch soon”. I'd welcome someone else taking
    that job.

 \     “Books and opinions, no matter from whom they came, if they are |
  `\     in opposition to human rights, are nothing but dead letters.” |
_o__)                                                  —Ernestine Rose |
Ben Finney

More information about the Python-list mailing list