[issue23227] Generator's finally block not run if close() called before first iteration

2015-05-14 Thread Martin Panter
Changes by Martin Panter : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-b

[issue23227] Generator's finally block not run if close() called before first iteration

2015-04-23 Thread Stephen Drake
Stephen Drake added the comment: Ok, I can accept that. I think my mistake was to assume that because a generator has a close() method, I could treat it as a lightweight wrapper for another closeable object. But it's better to regard a generator function that wraps an iterable as something m

[issue23227] Generator's finally block not run if close() called before first iteration

2015-04-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: This looks logical to me. The "finally" block is only entered if the "try" block is ever entered, but if you don't consume anything in the generator then the generator's code is never actually executed. -- nosy: +pitrou ___

[issue23227] Generator's finally block not run if close() called before first iteration

2015-04-22 Thread Marco Paolini
Marco Paolini added the comment: I think there is an issue in the way you designed your cleanup logic. So I think this issue is invalid. Usually, the code (funcion, class, ...) that *opens* the file should also be resposible of closing it. option 1) the caller opens and closes the file and wr

[issue23227] Generator's finally block not run if close() called before first iteration

2015-04-21 Thread Martin Panter
Changes by Martin Panter : -- nosy: +vadmium ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue23227] Generator's finally block not run if close() called before first iteration

2015-01-13 Thread R. David Murray
Changes by R. David Murray : -- nosy: +r.david.murray ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

[issue23227] Generator's finally block not run if close() called before first iteration

2015-01-12 Thread Stephen Drake
New submission from Stephen Drake: If a generator has its close() method called before any items are requested from it, a finally block in the generator function will not be executed. I encountered this when wrapping an open file to alter the result of iterating over it. Using a generator fun