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

Created on 2017-04-05 22:29 by serhiy.storchaka, last changed 2017-04-24 08:35 by berker.peksag.

Pull Requests
URL Status Linked Edit
PR 1011 open serhiy.storchaka, 2017-04-05 22:30
Messages (4)
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')

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.
Date User Action Args
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