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 <rep...@bugs.python.org>
<http://bugs.python.org/issue31286>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to