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

Include module name on ImportError #55565

Closed
ncoghlan opened this issue Feb 28, 2011 · 2 comments
Closed

Include module name on ImportError #55565

ncoghlan opened this issue Feb 28, 2011 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@ncoghlan
Copy link
Contributor

BPO 11356
Nosy @birkenfeld, @ncoghlan, @cool-RR
Superseder
  • bpo-1559549: ImportError needs attributes for module and file name
  • 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-03-01.06:35:45.408>
    created_at = <Date 2011-02-28.22:30:43.852>
    labels = ['interpreter-core', 'type-feature']
    title = 'Include module name on ImportError'
    updated_at = <Date 2011-03-01.06:35:45.406>
    user = 'https://github.com/ncoghlan'

    bugs.python.org fields:

    activity = <Date 2011-03-01.06:35:45.406>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-03-01.06:35:45.408>
    closer = 'georg.brandl'
    components = ['Interpreter Core']
    creation = <Date 2011-02-28.22:30:43.852>
    creator = 'ncoghlan'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 11356
    keywords = []
    message_count = 2.0
    messages = ['129729', '129741']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'ncoghlan', 'cool-RR']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'needs patch'
    status = 'closed'
    superseder = '1559549'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue11356'
    versions = ['Python 3.3']

    @ncoghlan
    Copy link
    Contributor Author

    Catching ImportError in order to switch to an alternate implementation can mask real failures in imported modules. Attaching the module name as an attribute would allow this to be handled correctly by doing something like:

    try:
    import simplejson
    except ImportError as err:
    if err.module_name != 'simplejson':
    raise
    <backup plan>

    See http://mail.python.org/pipermail/python-ideas/2011-February/009209.html

    @ncoghlan ncoghlan added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Feb 28, 2011
    @birkenfeld
    Copy link
    Member

    This is a dupe of bpo-1559549.

    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants