[Python-3000] Support for newline and encoding arguments to open in tempfile module, also mktemp deprecation

Adam Hupp adam at hupp.org
Tue Aug 28 03:58:51 CEST 2007


On 8/26/07, Guido van Rossum <guido at python.org> wrote:
>
> Hm, why not just create the temporary file in binary mode and wrap an
> io.TextIOWrapper instance around it?

That works, but leaves TemporaryFile with a text mode that is somewhat
crippled.  TemporaryFile unconditionally uses the default filesystem
encoding when in text mode so it can't be relied upon to hold
arbitrary strings.  This is error prone and confusing IMO.

An additional reason for adding newline and encoding: TemporaryFile
has always taken all of the optional arguments open() has, namely
'mode' and 'bufsize'.  There is a nice symmetry in adding these new
arguments as well.


-- 
Adam Hupp | http://hupp.org/adam/


More information about the Python-3000 mailing list