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

repr() of ImportError misses keyword arguments name and path #74185

Open
serhiy-storchaka opened this issue Apr 5, 2017 · 7 comments
Open

repr() of ImportError misses keyword arguments name and path #74185

serhiy-storchaka opened this issue Apr 5, 2017 · 7 comments
Assignees
Labels
3.13 new features, bugs and security fixes easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 29999
Nosy @brettcannon, @ncoghlan, @ericsnowcurrently, @berkerpeksag, @serhiy-storchaka, @remilapeyre
PRs
  • gh-74185: repr() of ImportError now contains attributes name and path. #1011
  • bpo-27015: Save kwargs given to exceptions constructor #11580
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = None
    created_at = <Date 2017-04-05.22:29:11.771>
    labels = ['interpreter-core', 'type-feature', '3.7']
    title = 'repr() of ImportError misses keyword arguments name and path'
    updated_at = <Date 2019-01-30.16:00:33.577>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2019-01-30.16:00:33.577>
    actor = 'remi.lapeyre'
    assignee = 'serhiy.storchaka'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2017-04-05.22:29:11.771>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29999
    keywords = ['patch']
    message_count = 5.0
    messages = ['291200', '291241', '291633', '292205', '334569']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'eric.snow', 'berker.peksag', 'serhiy.storchaka', 'remi.lapeyre']
    pr_nums = ['1011', '11580']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue29999'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    The repr of standard exceptions usually looks as exception constructor used for creating that exception. But the repr of ImportError misses keyword arguments name and path.

    >>> ImportError('test', name='somename', path='somepath')
    ImportError('test',)

    Proposed patch make the repr of ImportError containing keyword arguments.

    >>> ImportError('test', name='somename', path='somepath')
    ImportError('test', name='somename', path='somepath')

    I don't know how to classify this issue and whether the patch should be backported.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Apr 5, 2017
    @brettcannon
    Copy link
    Member

    I consider it an enhancement, especially if someone was slopping with their tests and explicitly checks the repr of ImportError.

    @brettcannon brettcannon added the type-feature A feature request or enhancement label Apr 6, 2017
    @serhiy-storchaka
    Copy link
    Member Author

    The patch also changes the repr of BaseException with a single argument. It no longer contains a trailing comma.

    @serhiy-storchaka serhiy-storchaka self-assigned this Apr 13, 2017
    @berkerpeksag
    Copy link
    Member

    Including 'path' may make the repr less readable in some cases. +1 for 'name', though.

    @remilapeyre
    Copy link
    Mannequin

    remilapeyre mannequin commented Jan 30, 2019

    I think the issue steems from the more general bpo-27015 for which a PR is ready that fixes the repr not only for ImportError but all other BaseException subclasses that override __init__.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added easy 3.12 bugs and security fixes and removed 3.7 (EOL) end of life labels Oct 29, 2022
    @iritkatriel
    Copy link
    Member

    The PRs need to be updated. Marking as easy.

    @furkanonder
    Copy link
    Sponsor Contributor

    @iritkatriel PR updated by @arhadthedev I think PR is ready to merge.

    @erlend-aasland erlend-aasland added 3.13 new features, bugs and security fixes and removed 3.12 bugs and security fixes labels Jan 5, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.13 new features, bugs and security fixes easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants