[issue6129] 2to3 does not convert imports of the form 'import sub.mod' to relative import

Mitchell Model report at bugs.python.org
Wed May 27 23:29:23 CEST 2009


Mitchell Model <mlm at acm.org> added the comment:

Yes, I meant to mention that: the directory sub does contain an
__init__.py with "__all__ = ['s']". I'm attaching a zip of the test
package pkg that contains the sub-package sub.

It wasn't clear to me what "import sub.s" should be converted to. By
analogy with the conversion of "import m" to "from . import m", I had
expected "import sub.s" to be converted "from . import sub.s". However,
that is a syntax error (which I don't understand, actually). What works
is "from sub import s" but that could import from a sub module found
anywhere; it isn't changed to a relative import. I don't see how to
write a relative import of a subpackage's module.

I don't doubt that I am confused about something here, but I've
experimented with many variations and can't get it straightened out.

----------
Added file: http://bugs.python.org/file14095/pkg.zip

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6129>
_______________________________________


More information about the Python-bugs-list mailing list