You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
2to3 creates illegal code on import a.b inside a package #57073
Activity
simohe commentedon Aug 30, 2011
When the current module is in a package and imports submodules, the following lines are converted to illegal code.
-import sub.subsub
+from . import sub.subsub
-import sub, sub.subsub, sub2
+from . import sub, sub.subsub, sub2
A valid alternative:
-import sub.subsub
+from .sub import subsub as _dummy
-import sub, sub.subsub, sub2
+from . import sub, sub2\nfrom .sub import subsub as _dummy
merwok commentedon Mar 25, 2012
-import sub.subsub
+from .sub import subsub as _dummy
That’s partly incorrect, as you need to bind the name sub to match the original code.
merwok commentedon Mar 25, 2012
BTW I think if this is too difficult to implement 2to3 could just be documented as requiring you not to use implicit relative imports.