Issue1141

classification
Title: Incorrect __import__ calls
Type: Severity: normal
Components: Core Versions: 2.5alpha3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: boisgera, fwierzbicki
Priority: Keywords:

Created on 2008-10-01.13:13:33 by boisgera, last changed 2008-11-14.22:56:23 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
diff.txt boisgera, 2008-10-01.13:13:32 patch
test.py boisgera, 2008-10-01.13:14:12 Test that exposes CPython/Jython differences
Messages
msg3632 (view) Author: (boisgera) Date: 2008-10-01.13:13:32
I have noticed differences in __import__ call arguments between Jython
and CPython. See below what module 'name' and 'fromlist' arguments are
when several import statements are used. CPython is used as the reference.

    $ jython test.py
    --------------------------------------------------
    statement: import hell.first_circle
      - expected: ('hell.first_circle', None)
      - got:      ('hell.first_circle', ())
    --------------------------------------------------
    statement: import hell.first_circle as limbo
      - expected: ('hell.first_circle', None)
      - got:      ('hell.first_circle', ('*',))
    --------------------------------------------------
    statement: from hell.ninth_circle import *
      - expected: ('hell.ninth_circle', ('*',))
      - got:      ('hell.ninth_circle', ('*',))
    --------------------------------------------------
    statement: from hell.ninth_circle import antaeus
      - expected: ('hell.ninth_circle', ('antaeus',))
      - got:      ('hell.ninth_circle', ('antaeus',))
    --------------------------------------------------
    statement: from hell.ninth_circle import antaeus as giant
      - expected: ('hell.ninth_circle', ('antaeus',))
      - got:      ('hell.ninth_circle', ('antaeus',))

    *** FAILURE: 2 errors ***

The first failure is minor: () is used instead of None to denote an
empty fromlist.

The second one is a bigger problem IMHO: it sends the wrong signal that
all symbols from hell.first_circle should be imported when only the
module is searched for. While this is not an issue with the standard
__builtin__.__import__ function, it  may be a pain when __import__ is
overriden -- that's how I discovered the issue in the first place. I've
produced a modified imp.java file that should address this second issue
(but not the first, empty tuples are still used, so there are still 2
errors even with the patch), see attached diff.txt
msg3782 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2008-11-14.22:56:22
Fixed in r5581.  By the way I made both of the differences return None
so that the exact CPython semantics are matched.
History
Date User Action Args
2008-11-14 22:56:23fwierzbickisetstatus: open -> closed
resolution: fixed
messages: + msg3782
2008-10-27 18:24:10fwierzbickisetassignee: fwierzbicki
nosy: + fwierzbicki
2008-10-01 13:14:12boisgerasetfiles: + test.py
2008-10-01 13:13:33boisgeracreate