classification
Title: HTTPError doesn't have a good "repr" representation
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, demian.brecht, facundobatista, martin.panter, python-dev
Priority: normal Keywords: patch

Created on 2015-04-08 11:44 by facundobatista, last changed 2015-04-23 03:19 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
issue23887.diff berker.peksag, 2015-04-08 12:35 review
Messages (6)
msg240262 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2015-04-08 11:44
I normally print(repr()) the exception I got, for debugging purposes. I use repr() because for builtin exceptions, str() will print only the message, and not the exception type.

But for HTTPError, the repr() of it is "HTTPError()", without further explanation...
msg240263 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-04-08 12:35
HTTPError.__str__ already provides useful information: ``'HTTP Error %s: %s' % (self.code, self.msg)``, but since the change is minimal and useful, here is a patch.
msg240269 - (view) Author: Demian Brecht (demian.brecht) * Date: 2015-04-08 15:01
A test really should be added for this. Otherwise, LGTM.
msg240462 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-04-11 05:36
Perhaps it would be more appropriate to set the BaseException.args attribute, or chain to its __init__() method, then you wouldn’t need a custom __repr__().
msg241257 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2015-04-16 18:33
Hi Berker, I like your patch, will apply it after doing a test for it.
msg241828 - (view) Author: Roundup Robot (python-dev) Date: 2015-04-22 21:36
New changeset e9ea679a92fa by Facundo Batista in branch 'default':
Issue #23887: urllib.error.HTTPError now has a proper repr() representation.
https://hg.python.org/cpython/rev/e9ea679a92fa
History
Date User Action Args
2015-04-23 03:19:50berker.peksagsetstage: patch review -> resolved
2015-04-22 21:49:10facundobatistasetstatus: open -> closed
resolution: fixed
2015-04-22 21:36:32python-devsetnosy: + python-dev
messages: + msg241828
2015-04-16 18:33:14facundobatistasetmessages: + msg241257
2015-04-11 05:36:23martin.pantersetnosy: + martin.panter
messages: + msg240462
2015-04-08 15:01:29demian.brechtsetnosy: + demian.brecht
messages: + msg240269
2015-04-08 12:35:21berker.peksagsetfiles: + issue23887.diff

type: enhancement
components: + Library (Lib)
versions: + Python 3.5, - Python 3.4
keywords: + patch
nosy: + berker.peksag

messages: + msg240263
stage: patch review
2015-04-08 11:44:13facundobatistacreate