Skip to content

relative imports don't work when circular #57396

Closed

Description

@pitrou
BPO 13187
Nosy @brettcannon, @ncoghlan, @pitrou, @florentx, @meadori, @ericsnowcurrently
Superseder
  • bpo-992389: attribute error due to circular import
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2011-10-16.06:44:55.414>
    created_at = <Date 2011-10-15.20:28:44.600>
    labels = ['interpreter-core', 'type-bug']
    title = "relative imports don't work when circular"
    updated_at = <Date 2011-10-16.06:44:55.413>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2011-10-16.06:44:55.413>
    actor = 'ncoghlan'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-10-16.06:44:55.414>
    closer = 'ncoghlan'
    components = ['Interpreter Core']
    creation = <Date 2011-10-15.20:28:44.600>
    creator = 'pitrou'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 13187
    keywords = []
    message_count = 2.0
    messages = ['145606', '145613']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'pitrou', 'flox', 'meador.inge', 'eric.snow']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '992389'
    type = 'behavior'
    url = 'https://bugs.python.org/issue13187'
    versions = ['Python 3.2', 'Python 3.3']

    Activity

    1. pitrou commented on Oct 15, 2011

      @pitrou
      MemberAuthor

      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
    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or error
      on Oct 15, 2011
    3. ncoghlan commented on Oct 16, 2011

      @ncoghlan
      Contributor

      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 bpo-992389

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions