[New-bugs-announce] [issue43129] Number of object on stack required by opcode

Matthieu Dartiailh report at bugs.python.org
Thu Feb 4 16:25:49 EST 2021


New submission from Matthieu Dartiailh <m.dartiailh at gmail.com>:

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.

----------
components: Library (Lib)
messages: 386494
nosy: mdartiailh
priority: normal
severity: normal
status: open
title: Number of object on stack required by opcode
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43129>
_______________________________________


More information about the New-bugs-announce mailing list