Message99368
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... |
|
Date |
User |
Action |
Args |
2010-02-15 19:28:10 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, pitrou, scoder, vstinner, benjamin.peterson, Arfrever |
2010-02-15 19:28:10 | amaury.forgeotdarc | set | messageid: <1266262090.11.0.270405558298.issue7173@psf.upfronthosting.co.za> |
2010-02-15 19:28:08 | amaury.forgeotdarc | link | issue7173 messages |
2010-02-15 19:28:08 | amaury.forgeotdarc | create | |
|