Issue 23887: HTTPError doesn't have a good "repr" representation (original) (raw)

Created on 2015-04-08 11:44 by facundobatista, last changed 2022-04-11 14:58 by admin. 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) * (Python triager) 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) (Python triager) 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
2022-04-11 14:58:15 admin set github: 68075
2015-04-23 03:19:50 berker.peksag set stage: patch review -> resolved
2015-04-22 21:49:10 facundobatista set status: open -> closedresolution: fixed
2015-04-22 21:36:32 python-dev set nosy: + python-devmessages: +
2015-04-16 18:33:14 facundobatista set messages: +
2015-04-11 05:36:23 martin.panter set nosy: + martin.pantermessages: +
2015-04-08 15:01:29 demian.brecht set nosy: + demian.brechtmessages: +
2015-04-08 12:35:21 berker.peksag set files: + issue23887.difftype: enhancementcomponents: + Library (Lib)versions: + Python 3.5, - Python 3.4keywords: + patchnosy: + berker.peksagmessages: + stage: patch review
2015-04-08 11:44:13 facundobatista create