Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show clear error message on circular import #64689

Closed
cool-RR mannequin opened this issue Feb 2, 2014 · 6 comments
Closed

Show clear error message on circular import #64689

cool-RR mannequin opened this issue Feb 2, 2014 · 6 comments
Labels
3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@cool-RR
Copy link
Mannequin

cool-RR mannequin commented Feb 2, 2014

BPO 20490
Nosy @brettcannon, @bitdancer, @cool-RR, @1st1, @zooba, @asottile, @pablogsal
PRs
  • bpo-20490: Improve circular import error messaging #15308
  • [3.8] bpo-20490: Improve circular import error message (GH-15308) #15791
  • 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 2019-09-09.15:48:07.477>
    created_at = <Date 2014-02-02.19:04:48.278>
    labels = ['interpreter-core', 'type-feature', '3.8', '3.9']
    title = 'Show clear error message on circular import'
    updated_at = <Date 2019-09-10.13:06:52.667>
    user = 'https://github.com/cool-RR'

    bugs.python.org fields:

    activity = <Date 2019-09-10.13:06:52.667>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-09.15:48:07.477>
    closer = 'steve.dower'
    components = ['Interpreter Core']
    creation = <Date 2014-02-02.19:04:48.278>
    creator = 'cool-RR'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 20490
    keywords = ['patch']
    message_count = 6.0
    messages = ['210006', '210153', '351496', '351505', '351529', '351642']
    nosy_count = 8.0
    nosy_names = ['brett.cannon', 'Arfrever', 'r.david.murray', 'cool-RR', 'yselivanov', 'steve.dower', 'Anthony Sottile', 'pablogsal']
    pr_nums = ['15308', '15791']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue20490'
    versions = ['Python 3.8', 'Python 3.9']

    @cool-RR
    Copy link
    Mannequin Author

    cool-RR mannequin commented Feb 2, 2014

    If there's a circular import in my program, I don't want to see an error message, "Cannot import name 'foo'" and then say in my mind, "ah, I'm an experienced Python developer, I know that when Python says that it often means that there's a circular import problem." I want the error message to **say there's a circular import problem**, so (a) I won't have to remember this piece of trivia and (b) less experienced developers won't have to bang their heads on their desks trying to figure out why the import isn't working.

    Bonus points if the error message actually shows which module is trying to import a module that imports itself, so we'll know where to fix.

    @cool-RR cool-RR mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Feb 2, 2014
    @brettcannon
    Copy link
    Member

    It's not as simple as it sounds because failures from "from ... import ..." are triggered in the eval loop and not in import and without thinking it through I don't know if you could use the fine-grained import locks to inspect if something is in the middle of being imported or not that way.

    @asottile asottile mannequin added 3.8 only security fixes 3.9 only security fixes labels Aug 15, 2019
    @zooba
    Copy link
    Member

    zooba commented Sep 9, 2019

    New changeset 65366bc by Steve Dower (Anthony Sottile) in branch 'master':
    bpo-20490: Improve circular import error message (GH-15308)
    65366bc

    @zooba
    Copy link
    Member

    zooba commented Sep 9, 2019

    Thanks for the patch, Anthony!

    @zooba zooba closed this as completed Sep 9, 2019
    @zooba
    Copy link
    Member

    zooba commented Sep 9, 2019

    New changeset 2d5594f by Steve Dower in branch '3.8':
    bpo-20490: Improve circular import error message (GH-15308)
    2d5594f

    @pablogsal
    Copy link
    Member

    This PR introduced a reference leak tracked in:

    https://bugs.python.org/issue38090

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants