Author ethan.furman
Recipients Carl Osterwisch, Gabi.Davar, John Florian, chary314, dabrahams, davide.rizzo, dlenski, eric.araujo, eric.smith, eryksun, ethan smith, ethan.furman, ev2geny, jaraco, jwilk, martin.panter, ncoghlan, njs, paul.moore, piotr.dobrogost, pitrou, r.david.murray, sbt, steve.dower, tim.golden, zach.ware
Date 2021-04-07.23:43:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617839029.37.0.392511732721.issue14243@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2021-04-07 23:43:49ethan.furmansetrecipients: + ethan.furman, paul.moore, jaraco, ncoghlan, pitrou, eric.smith, tim.golden, jwilk, eric.araujo, r.david.murray, njs, dabrahams, davide.rizzo, sbt, Gabi.Davar, martin.panter, piotr.dobrogost, zach.ware, dlenski, eryksun, steve.dower, Carl Osterwisch, ethan smith, John Florian, ev2geny, chary314
2021-04-07 23:43:49ethan.furmansetmessageid: <1617839029.37.0.392511732721.issue14243@roundup.psfhosted.org>
2021-04-07 23:43:49ethan.furmanlinkissue14243 messages
2021-04-07 23:43:48ethan.furmancreate