This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 'compiler' module bug with 'import foo.bar as baz'
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mwh Nosy List: mrpr, mwh
Priority: normal Keywords: patch

Created on 2003-06-06 09:47 by mrpr, last changed 2022-04-10 16:09 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
thePatch.txt mrpr, 2003-06-06 09:47 Patch for compiler/pycodegen.py bug.
Messages (2)
msg43906 - (view) Author: Ronny Wikh (mrpr) Date: 2003-06-06 09:47
Python package 'compiler' generates incorrect code for
statements on
the format 'import foo.bar as baz'. Code to illustrate
this follows:

-----------------------

program = '''
import foo.bar as baz
'''

code1 = compile(program, 'foobar', 'exec')
code2 = compiler.compile(program, 'foobar', 'exec')

print 'CODE builtin'
dis.disassemble(code1)
print
print 'CODE compiler package'
dis.disassemble(code2)

-----------------------

With the output:

-----------------------


CODE builtin
          0 SET_LINENO               0

          3 SET_LINENO               2
          6 LOAD_CONST               0 (None)
          9 IMPORT_NAME              0 (foo.bar)
         12 LOAD_ATTR                1 (bar)
         15 STORE_NAME               2 (baz)
         18 LOAD_CONST               0 (None)
         21 RETURN_VALUE

CODE compiler package
          0 SET_LINENO               0

          3 SET_LINENO               2
          6 LOAD_CONST               0 (None)
          9 IMPORT_NAME              0 (foo.bar)
         12 STORE_NAME               1 (baz)
         15 LOAD_CONST               0 (None)
         18 RETURN_VALUE

-----------------------

The attached patch fixes this bug
msg43907 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-06-27 12:33
Logged In: YES 
user_id=6656

Yup.

Lib/compiler/pycodegen.py revision 1.65
History
Date User Action Args
2022-04-10 16:09:03adminsetgithub: 38600
2003-06-06 09:47:21mrprcreate