This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gpk-kochanski
Recipients gpk-kochanski
Date 2011-02-19.10:50:43
SpamBayes Score 2.0005697e-07
Marked as misclassified No
Message-id <1298112645.15.0.0904865308119.issue11248@psf.upfronthosting.co.za>
In-reply-to
Content
When you have a generator as an argument to zip(), code after the last yield statement may not get executed.  The problem is that zip() stops after it gets _one_ exception, i.e. when just one of the generators has finished.

As a result, if there were any important clean-up code at the end of a generator, it will not be executed.   Caches may not get flushed, et cetera.

At the least, this is a documentation bug that needs to be pointed out in both zip() and the definition of a generator().  More realistically, it is a severe wart on the language, because it violates the programmer's reasonable expectation that a generator executes until it falls off the end of the function.  It means that a generator becomes conceptually nasty: you cannot predict what it will do based just on an inspection of the code and the code it calls.

Likely, the same behavior happens in itertools, too.
History
Date User Action Args
2011-02-19 10:50:45gpk-kochanskisetrecipients: + gpk-kochanski
2011-02-19 10:50:45gpk-kochanskisetmessageid: <1298112645.15.0.0904865308119.issue11248@psf.upfronthosting.co.za>
2011-02-19 10:50:44gpk-kochanskilinkissue11248 messages
2011-02-19 10:50:44gpk-kochanskicreate