New submission from ganges master <[email protected]>:
the relative-import mechanism is broken... at least on python2.6 but i'd guess
on later versions as well.
consider this package layout:
/tmp/foo/
/tmp/foo/__init__.py
/tmp/foo/bar.py
where bar.py is:
# note this is a relative import and should fail!
from .os import walk
print walk
# and this should also fail
from . import os
print os
running it yields a bug:
$ PYTHONPATH="/tmp" python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo.bar
<function walk at 0xb7d2aa04> # <<<< ?!?!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/foo/bar.py", line 4, in <module>
from . import os
ImportError: cannot import name os
"from . import os" fails as expected, but "from .os import walk" works --
although it should obviously fail too.
-tomer
----------
components: Interpreter Core
files: bar.py
messages: 99176
nosy: gangesmaster
severity: normal
status: open
title: relative import broken
versions: Python 2.6
Added file: http://bugs.python.org/file16201/bar.py
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7902>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com