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=Nonecreated_at=<Date2017-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=<Date2019-01-30.16:00:33.577>user='https://github.com/serhiy-storchaka'
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.
Including 'path' may make the repr less readable in some cases. +1 for 'name', though.
remilapeyre commented on Jan 30, 2019
remilapeyremannequin
Mannequin
More actions
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__.
Activity
serhiy-storchaka commented on Apr 5, 2017
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.
Proposed patch make the repr of ImportError containing keyword arguments.
I don't know how to classify this issue and whether the patch should be backported.
brettcannon commented on Apr 6, 2017
I consider it an enhancement, especially if someone was sloppy with their tests and explicitly checks the repr of ImportError.
serhiy-storchaka commented on Apr 13, 2017
The patch also changes the repr of BaseException with a single argument. It no longer contains a trailing comma.
berkerpeksag commented on Apr 24, 2017
Including 'path' may make the repr less readable in some cases. +1 for 'name', though.
remilapeyre commented on 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__.
iritkatriel commented on Oct 29, 2022
The PRs need to be updated. Marking as easy.
furkanonder commented on Mar 4, 2023
@iritkatriel PR updated by @arhadthedev I think PR is ready to merge.
ynir3 commented on Jul 20, 2025
trying to revive this issue by building on the previous PRs #136770
gh-74185: repr() of ImportError now contains attributes name and path (…
vstinner commented on Aug 14, 2025
Implemented by c87b66b.
pythongh-74185: repr() of ImportError now contains attributes name an…