Ethan Furman <et...@stoneleaf.us> added the comment:

I think the best solution, albeit slightly backwards incompatible, is to change 
NamedTemporaryFile such that if (and only if) it is being used as a context 
manager, the underlying file is not closed until the context manager ends.  
This should be the default behavior with no new flags.

Since context managers are used for resource acquisition (`__enter__`) and 
cleanup (`__exit__`), having the resource disappear in the middle of the `with` 
block is counter-intuitive.

Given that closing a file in the middle of its CM seems like a very odd thing 
to do (one could just leave the CM and the file would close), do we need a 
deprecation period or can we just make the change?

----------
nosy: +ethan.furman
title: tempfile.NamedTemporaryFile not particularly useful on   Windows -> 
tempfile.NamedTemporaryFile not particularly useful on Windows

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue14243>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to