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 nascheme
Recipients Demur Rumed, Mark.Shannon, benjamin.peterson, christian.heimes, mark.dickinson, nascheme, ncoghlan, pitrou, rhettinger, serhiy.storchaka, trent
Date 2017-12-05.17:21:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1512494471.85.0.213398074469.issue17611@psf.upfronthosting.co.za>
In-reply-to
Content
There is some more explanation in the PR and sample code.

We unwind, if we hit a finally fblock, we emit code of the body of it.  If inside the block, there is another return statement, we unwind again.  That causes an infinite loop in the compiler.

The commit 0610860 is a fix, I think.  I have a cleaner version but haven't pushed it yet.  There are still some remaining bugs though, caused by "return" in the finally body.  The problem as I see it is that "unwind_exception" in ceval pushes a EXCEPT_HANDLER fblock if we are inside a SETUP_EXCEPT or SETUP_FINALLY block.  If there is a return in the finally body, the compiler doesn't know if it should POP_BLOCK or not.  At least, that is my understanding now.

I think the best way forward is to split this patch into multiple parts.  I have a simple patch that changes fblockinfo to be a singly linked list (like blockinfo).  Next, I think we could change the exception opcodes to have a fixed stack effect (don't think that requires unwind to be done by compiler).  Rather than pushing three values for an exception, could we just build a tuple and push that?  Seems simpler to me vs having ROT_FOUR. Finally, we can tackle the compiler based unwind.
History
Date User Action Args
2017-12-05 17:21:11naschemesetrecipients: + nascheme, rhettinger, mark.dickinson, ncoghlan, pitrou, christian.heimes, benjamin.peterson, trent, Mark.Shannon, serhiy.storchaka, Demur Rumed
2017-12-05 17:21:11naschemesetmessageid: <1512494471.85.0.213398074469.issue17611@psf.upfronthosting.co.za>
2017-12-05 17:21:11naschemelinkissue17611 messages
2017-12-05 17:21:11naschemecreate