Author gangesmaster
Recipients gangesmaster
Date 2010-02-10.19:09:20
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1265828963.53.0.5315107426.issue7902@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2010-02-10 19:09:23gangesmastersetrecipients: + gangesmaster
2010-02-10 19:09:23gangesmastersetmessageid: <1265828963.53.0.5315107426.issue7902@psf.upfronthosting.co.za>
2010-02-10 19:09:21gangesmasterlinkissue7902 messages
2010-02-10 19:09:20gangesmastercreate