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 amaury.forgeotdarc
Recipients Arfrever, amaury.forgeotdarc, benjamin.peterson, pitrou, scoder, vstinner
Date 2010-02-15.19:28:08
SpamBayes Score 0.0011487749
Marked as misclassified No
Message-id <1266262090.11.0.270405558298.issue7173@psf.upfronthosting.co.za>
In-reply-to
Content
Is it normal that even after the call to next(), the generator frame contains a reference to the RuntimeError?

Long explanation:
- When the function exits, there is a cycle [parent frame]-> ['it' variable]-> [generator frame]-> [RuntimeError]-> [parent frame].
- gc.collect() collects them all, destroys the generator, this causes GeneratorExit exception to be sent into the generator frame.
- This executes SWAP_EXC_STATE() in ceval.c ("/* We were in an except handler when we left, restore the exception state which was put aside */"), this *moves* the reference to the exception from the frame to the thread state.
- The exception is resurrected, but this does not prevent the gc from calling its tp_clear method! and setting exc_info() as a side-effect of gc.collect() is really weird...
History
Date User Action Args
2010-02-15 19:28:10amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, pitrou, scoder, vstinner, benjamin.peterson, Arfrever
2010-02-15 19:28:10amaury.forgeotdarcsetmessageid: <1266262090.11.0.270405558298.issue7173@psf.upfronthosting.co.za>
2010-02-15 19:28:08amaury.forgeotdarclinkissue7173 messages
2010-02-15 19:28:08amaury.forgeotdarccreate