Message10130
Wildcard imports from a module using `from future import absolute_import` fails to correctly find the targeted module in the same package.
Expected behaviour (under Python 2.7):
$ PYTHONPATH=~/jython-bug python2.7 -m foo.foo
BAR: 42
Actual behaviour:
$ JYTHONPATH=~/jython-bug java -jar ./jython-standalone-2.7.0.jar -m foo.foo
Traceback (most recent call last):
File "/home/dcoles/jython-standalone-2.7.0.jar/Lib/runpy.py", line 161, in _run_module_as_main
File "/home/dcoles/jython-standalone-2.7.0.jar/Lib/runpy.py", line 72, in _run_code
File "/home/dcoles/jython-bug/foo/foo.py", line 2, in <module>
from .bar import *
ImportError: No module named bar
This can be reproduced using the following setup:
foo/__init__.py
===============
pass
foo/foo.py
==========
from __future__ import absolute_import
from .bar import *
if __name__ == "__main__":
print("BAR: %s" % BAR)
foo/bar.py
==========
BAR = 42
It appears that rather than searching the libraries path, it searches the current working directory:
# from .bar import *
import: trying source /home/dcoles/bar
import: trying precompiled with no source /home/dcoles/bar$py.class
# from foo.bar import *
import: trying source /home/dcoles/jython-bug/foo/bar
import: trying precompiled /home/dcoles/jython-bug/foo/bar$py.class
A workaround is to switch the import style so as not to use package
relative imports. |
|
Date |
User |
Action |
Args |
2015-06-23 17:43:53 | dcoles | set | recipients:
+ dcoles |
2015-06-23 17:43:53 | dcoles | set | messageid: <1435081433.74.0.235662668073.issue2372@psf.upfronthosting.co.za> |
2015-06-23 17:43:53 | dcoles | link | issue2372 messages |
2015-06-23 17:43:52 | dcoles | create | |
|