Message386494
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. |
|
Date |
User |
Action |
Args |
2021-02-04 21:25:49 | mdartiailh | set | recipients:
+ mdartiailh |
2021-02-04 21:25:49 | mdartiailh | set | messageid: <1612473949.46.0.297177775699.issue43129@roundup.psfhosted.org> |
2021-02-04 21:25:49 | mdartiailh | link | issue43129 messages |
2021-02-04 21:25:48 | mdartiailh | create | |
|