This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: repr() of ImportError misses keyword arguments name and path
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: berker.peksag, brett.cannon, eric.snow, ncoghlan, remi.lapeyre, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-04-05 22:29 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 1011 open serhiy.storchaka, 2017-04-05 22:30
PR 11580 remi.lapeyre, 2019-01-30 16:00
Messages (5)
msg291200 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-05 22:29
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.
msg291241 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2017-04-06 17:56
I consider it an enhancement, especially if someone was slopping with their tests and explicitly checks the repr of ImportError.
msg291633 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-13 21:24
The patch also changes the repr of BaseException with a single argument. It no longer contains a trailing comma.
msg292205 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-04-24 08:35
Including 'path' may make the repr less readable in some cases. +1 for 'name', though.
msg334569 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-01-30 16:00
I think the issue steems from the more general #27015 for which a PR is ready that fixes the repr not only for ImportError but all other BaseException subclasses that override __init__.
History
Date User Action Args
2022-04-11 14:58:45adminsetgithub: 74185
2019-01-30 16:00:33remi.lapeyresetnosy: + remi.lapeyre
messages: + msg334569
pull_requests: + pull_request11554

keywords: + patch
2017-04-24 08:35:04berker.peksagsetnosy: + berker.peksag
messages: + msg292205
2017-04-13 21:24:25serhiy.storchakasetassignee: serhiy.storchaka
messages: + msg291633
2017-04-06 17:56:01brett.cannonsettype: enhancement
messages: + msg291241
2017-04-05 22:30:49serhiy.storchakasetpull_requests: + pull_request1179
2017-04-05 22:29:11serhiy.storchakacreate