[New-bugs-announce] [issue32455] PyCompile_OpcodeStackEffect() and dis.stack_effect() are not particularly useful

Serhiy Storchaka report at bugs.python.org
Sat Dec 30 09:05:46 EST 2017


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

The information provided by PyCompile_OpcodeStackEffect() and dis.stack_effect() (added in issue19722) is not enough for practical use.

1. Some opcodes (like JUMP_IF_TRUE_OR_POP or FOR_ITER) have different stack effect when when execution is continued from the following opcode or jumped to the address specified by oparg. Thus there are two different values for stack effect of these opcodes.

2. Some opcodes (RETURN_VALUE, RAISE_VARARGS) stops execution. Their stack effect doesn't have meaning, and the following opcodes should be ignored.

3. Some opcodes (JUMP_ABSOLUTE, JUMP_RELATIVE) always jump. The opcodes following them should be ignored.

4. Some opcodes (like SETUP_FINALLY or SETUP_WITH) need additional space on the stack for raised exceptions. Their stack effect is virtual. Its value can't be used for calculating the actual position on the stack. This isn't documented.

The possible solution is to add a boolean flag for distinguishing the stack effects in case of consequent execution and jumping. Return a special sentinel or raise an exception if the opcode doesn't pass execution in this direction.

----------
components: Interpreter Core, Library (Lib)
messages: 309232
nosy: eric.snow, larry, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: PyCompile_OpcodeStackEffect() and dis.stack_effect() are not particularly useful
type: enhancement
versions: Python 3.7

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


More information about the New-bugs-announce mailing list