[issue31286] import in finally results in SystemError

Serhiy Storchaka report at bugs.python.org
Sun Aug 27 02:33:45 EDT 2017


Serhiy Storchaka added the comment:

The regression was introduced in issue30024. It was missed a difference between LOAD_ATTR and IMPORT_FROM. LOAD_ATTR replaces the object with the value of the attribute (do not changing the stack pointer). IMPORT_FROM keeps the original module on the stack and pushes the value of the attribute increasing the stack pointer.

There are two ways of fixing this issue.

1. Add two instructions ROT_TWO and POP_TOP after every IMPORT_FROM in the bytecode generated from "import a.b.c as d".

2. Make IMPORT_FROM popping the original module from the stack. The explicit DUP_TOP instruction should be inserted before every IMPORT_FROM in the bytecode generated from "from a import b, c".

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31286>
_______________________________________


More information about the Python-bugs-list mailing list