➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: 2to3 creates illegal code on import a.b inside a package
类型: Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.2, Python 3.3, Python 2.7
process
状态: closed Resolution: wont fix
Dependencies: 后续: Close 2to3 issues and list them here
View: 45544
分配给: 抄送列表: benjamin.peterson, eric.araujo, meador.inge, simohe
优先级: normal 关键字:

Created on 2011-08-30 21:59 by simohe, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg143237 - (view) Author: simohe (simohe) 日期: 2011-08-30 21:59
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
msg156737 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) 日期: 2012-03-25 07:03
-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.
msg156738 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) 日期: 2012-03-25 07:04
BTW I think if this is too difficult to implement 2to3 could just be documented as requiring you not to use implicit relative imports.
历史
日期 用户 动作 参数
2022-04-11 14:57:21admin修改github: 57073
2021-10-20 22:40:51iritkatriel修改resolution: duplicate -> wont fix
2021-10-20 22:37:18iritkatriel修改状态: open -> closed
后续: Close 2to3 issues and list them here
resolution: duplicate
stage: needs patch -> resolved
2012-03-30 02:00:41meador.inge修改抄送: + meador.inge
2012-03-25 07:04:17eric.araujo修改消息: + msg156738
2012-03-25 07:03:35eric.araujo修改抄送: + eric.araujo
消息: + msg156737
2011-09-02 16:59:43eric.araujo修改抄送: + benjamin.peterson
stage: needs patch

versions: + Python 2.7, Python 3.2, Python 3.3, - Python 2.6, Python 3.1
2011-08-30 21:59:21simohe创建