Repository navigation
repr() of ImportError misses keyword arguments name and path #74185
Description
Activity
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.
I consider it an enhancement, especially if someone was sloppy with their tests and explicitly checks the repr of ImportError.
The patch also changes the repr of BaseException with a single argument. It no longer contains a trailing comma.
Including 'path' may make the repr less readable in some cases. +1 for 'name', though.
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__.
The PRs need to be updated. Marking as easy.
@iritkatriel PR updated by @arhadthedev I think PR is ready to merge.
trying to revive this issue by building on the previous PRs #136770
Implemented by c87b66b.
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:
bugs.python.org fields:
Linked PRs