Issue1871

classification
Title: Relative import in module gets imported to top level (regression)
Type: behaviour Severity: normal
Components: Core Versions: 2.5.3b1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: fwierzbicki, jeff250
Priority: high Keywords:

Created on 2012-03-31.05:31:17 by jeff250, last changed 2012-05-15.02:07:00 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
jython-bug.tar.gz jeff250, 2012-03-31.05:31:17
jython-bug-time.tar.gz jeff250, 2012-03-31.05:38:54
Messages
msg6992 (view) Author: Jeffrey Knockel (jeff250) Date: 2012-03-31.05:31:17
This regression was introduced in changeset 6254:4c672dbbcdb2...
http://hg.python.org/jython/rev/4c672dbbcdb2?revcount=960

Suppose we have file structure:
somemodule/__init__.py
somemodule/somesubmodule.py

And somemodule/__init__.py contains import:
from . import somesubmodule

Then when we import somemodule, we have both 'somemodule.somesubmodule' *and* 'somesubmodule' (without a 'somemodule.' prefix) in sys.modules instead of just 'somemodule.somesubmodule'.  See the attached tarball for reproducing code.

One side effect of this bug is if the submodule has a name of another top level module name like 'time', then we can no longer import the real top level 'time' module after importing 'somemodule'.

The line where the bad entry is added is where we have:

modules.__setitem__(fullName, ret);

in the import_next method in org.python.core.imp.
msg6993 (view) Author: Jeffrey Knockel (jeff250) Date: 2012-03-31.05:38:54
Also attaching an example where after the time submodule is imported we can no longer import the real top-level time module.
msg7047 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-04-11.17:37:20
Sorry for the slow response Jeffrey, I have reproduced the bug and will make sure it is fixed for 2.5.3b2
msg7091 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-05-15.02:06:40
Fixed in 2.5 branch and default (2.7) branch.
History
Date User Action Args
2012-05-15 02:07:00fwierzbickisettype: behaviour
2012-05-15 02:06:41fwierzbickisetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg7091
2012-04-11 17:37:20fwierzbickisetpriority: high
assignee: fwierzbicki
resolution: accepted
messages: + msg7047
2012-03-31 18:14:29fwierzbickisetnosy: + fwierzbicki
2012-03-31 05:38:54jeff250setfiles: + jython-bug-time.tar.gz
messages: + msg6993
2012-03-31 05:31:17jeff250create