[Python-Dev] The purpose of SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP
P.J. Eby
pje at telecommunity.com
Sat Mar 12 20:04:07 CET 2011
At 08:25 AM 3/12/2011 -0500, Eugene Toder wrote:
>Right, I'm not suggesting to remove all blocks, only SETUP_LOOP
>blocks. Do you see the problem in that case?
I think you guys are forgetting about FOR_ITER, listcomps, and the like.
That is, IIRC, the reason loops use the block stack is because they
put things on the regular stack, that need to be cleared off the
stack when the loop is exited (whether normally or via an exception).
In other words, just jumping out of a loop without popping the block
stack would leave junk on the regular stack, thereby failing to
deallocate the loop iterator. In the case of a nested loop, this
would also mean that the outer loop would start using the inner
loop's iterator, and all sorts of hilarity would then ensue.
More information about the Python-Dev
mailing list