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 mdartiailh
Recipients mdartiailh
Date 2021-02-04.21:25:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612473949.46.0.297177775699.issue43129@roundup.psfhosted.org>
In-reply-to
Content
When constructing bytecode object manually as can be done using the bytecode library (https://github.com/MatthieuDartiailh/bytecode which was first developed by V Stinner), one can use dis.stack_effect to compute the required stack size, thus avoiding stack overflows.

However it can be interesting for those manually built bytecode object to also check that no underflow can occur. This computation is straightforward once one knows the number of element on the stack a specific opcode expects. 

This works has been done manually in the bytecode project, but it may interesting to provide a way in the dis module to access this information with an interface similar to dis.stack_effect.

If there is an interest in such a feature I would be happy to contribute it. I would however like some opinion on how to do that in an optimal manner. I assume it would require to add the implementation in https://github.com/python/cpython/blob/master/Python/compile.c and expose it in a similar manner to stack_effect.
History
Date User Action Args
2021-02-04 21:25:49mdartiailhsetrecipients: + mdartiailh
2021-02-04 21:25:49mdartiailhsetmessageid: <1612473949.46.0.297177775699.issue43129@roundup.psfhosted.org>
2021-02-04 21:25:49mdartiailhlinkissue43129 messages
2021-02-04 21:25:48mdartiailhcreate