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

ImportError.__init__ doesn't reset not specified exception attributes #72476

serhiy-storchaka opened this issue Sep 27, 2016 · 7 comments
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs)


Copy link

BPO 28289
Nosy @brettcannon, @ncoghlan, @ericsnowcurrently, @serhiy-storchaka
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • importerror-reset-attributes.patch
  • 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 = ''
    closed_at = <Date 2016-09-28.04:54:25.778>
    created_at = <Date 2016-09-27.18:02:52.142>
    labels = ['interpreter-core', '3.7']
    title = "ImportError.__init__ doesn't reset not specified exception attributes"
    updated_at = <Date 2017-03-31.16:36:31.261>
    user = '' fields:

    activity = <Date 2017-03-31.16:36:31.261>
    actor = 'dstufft'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-09-28.04:54:25.778>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-09-27.18:02:52.142>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['44848']
    hgrepos = []
    issue_num = 28289
    keywords = ['patch']
    message_count = 7.0
    messages = ['277533', '277537', '277547', '277554', '277555', '277581', '277710']
    nosy_count = 5.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'python-dev', 'eric.snow', 'serhiy.storchaka']
    pr_nums = ['552']
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = ''
    versions = ['Python 3.7']

    Copy link
    Member Author

    ImportError.__init__ sets only specified attributes ("msg", "name" or "path"), and left not explicitly specified attributes unchanged.

    >>> err = ImportError('test', name='name')
    >>> err.args, err.msg,, err.path
    (('test',), 'test', 'name', None)
    >>> err.__init__(path='path')
    >>> err.args, err.msg,, err.path
    ((), 'test', 'name', 'path')

    In above example err.__init__(path='path') sets attributes "args" and "path", but not "msg" and "name".

    I'm not sure whether can this be considered as a bug.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Sep 27, 2016
    Copy link

    I think it's a bug, but a low priority one.

    Copy link
    Member Author

    Here is a simple patch.

    But I'm not sure that this is a bug.

    Copy link

    Patch LGTM.

    Copy link

    And I say don't worry about backporting.

    Copy link
    Member Author

    Thanks Brett.

    Copy link

    python-dev mannequin commented Sep 29, 2016

    New changeset dcb39d3ba67a by Serhiy Storchaka in branch 'default':
    Issue bpo-28289: ImportError.__init__ now resets not specified attributes.

    @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
    3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs)
    None yet

    No branches or pull requests

    2 participants