Re: [Python-Dev] Fun with ExitStack

2016-07-18 Thread Nick Coghlan
On 19 July 2016 at 09:40, Barry Warsaw wrote: > Ah, the try-finally changes the behavior! There's probably some documentation > somewhere that defines how a generator gets finalized, and that triggers the > finally clause, whereas in the previous example, nothing after the yield gets > run. I ju

Re: [Python-Dev] Fun with ExitStack

2016-07-18 Thread Martin Panter
On 18 July 2016 at 23:40, Barry Warsaw wrote: > I was trying to debug a problem in some work code and I ran into some > interesting oddities with contextlib.ExitStack and other context managers in > Python 3.5. > > This program creates a temporary directory, and I wanted to give it a --keep > flag

[Python-Dev] Fun with ExitStack

2016-07-18 Thread Barry Warsaw
I was trying to debug a problem in some work code and I ran into some interesting oddities with contextlib.ExitStack and other context managers in Python 3.5. This program creates a temporary directory, and I wanted to give it a --keep flag to not automatically delete the tempdir at program exit.