classification
Title: relative imports don't work when circular
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: duplicate
Dependencies: Superseder: attribute error due to circular import
View: 992389
Assigned To: Nosy List: brett.cannon, eric.snow, flox, meador.inge, ncoghlan, pitrou
Priority: normal Keywords:

Created on 2011-10-15 20:28 by pitrou, last changed 2011-10-16 06:44 by ncoghlan. This issue is now closed.

Messages (2)
msg145606 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-10-15 20:28
This is, to say the least, annoying.

$ mkdir mypackage
$ touch mypackage/__init__.py
$ echo "from . import b" > mypackage/a.py
$ echo "from . import a" > mypackage/b.py
$ ./python -c "import mypackage.a"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "mypackage/a.py", line 1, in <module>
    from . import b
  File "mypackage/b.py", line 1, in <module>
    from . import a
ImportError: cannot import name a
msg145613 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-10-16 06:44
This is the same problem that all "from x import y" circular imports have - it isn't specific to relative imports.

Closing as a duplicate of issue 992389
History
Date User Action Args
2011-10-16 06:44:55ncoghlansetstatus: open -> closed
resolution: duplicate
superseder: attribute error due to circular import
messages: + msg145613
2011-10-15 22:20:47meador.ingesetnosy: + meador.inge
2011-10-15 20:58:30eric.snowsetnosy: + eric.snow
2011-10-15 20:32:15floxsetnosy: + flox
2011-10-15 20:30:54pitrousetnosy: + brett.cannon
2011-10-15 20:28:44pitroucreate