[Patches] [ python-Patches-750008 ] 'compiler' module bug with 'import foo.bar as baz'

SourceForge.net noreply@sourceforge.net
Fri, 06 Jun 2003 02:47:24 -0700


Patches item #750008, was opened at 2003-06-06 11:47
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=750008&group_id=5470

Category: Parser/Compiler
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Ronny Wikh (mrpr)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'compiler' module bug with 'import foo.bar as baz'

Initial Comment:
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


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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=750008&group_id=5470