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

Guido van Rossum guido at python.org
Tue Aug 28 04:03:22 CEST 2007


OK, I think you've convinced me.

Now, how about also making the default mode be text instead of binary?
I've got a hunch that text files are used more than binary files, even
where temporary files are concerned.

--Guido

On 8/27/07, Adam Hupp <adam at hupp.org> wrote:
> 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/
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list