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: HTTPError interface changes / breaks depending on what was passed to constructor
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Keto, berker.peksag, demian.brecht, eric.araujo, ezio.melotti
Priority: normal Keywords: patch

Created on 2011-12-09 15:54 by Keto, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
httperror-geturl-fix-2.patch Keto, 2011-12-09 15:54 HTTPError patch for 2.7 review
httperror-geturl-fix-3.patch Keto, 2011-12-09 16:18 HTTPError patch for 3.3 review
Messages (2)
msg149106 - (view) Author: Pami Ketolainen (Keto) Date: 2011-12-09 15:54
In case of authentication error, HTTPError gets initialized without file object and constructor of addinfourl is not called. This means that url attribute is not set and geturl() (inherited from addinfourl) raises AttributeError.

geturl() is not documented as part of HTTPError interface, so I'm not sure if it is correct to expect it to work. And of course this can be worked around by using the HTTPError.filename which always contains the url passed to constructor.

How ever, I have made a simple patch to fix the missing attribute.


There is also Issue5286 with a patch, which makes the http_error_auth_reqed pass the fp to HTTPError making it a file-like object as stated in the documentation. So that would probably be the correct solution.

IMHO it's a bit bad design, when objects interface changes depending on how it was initialized.
msg149107 - (view) Author: Pami Ketolainen (Keto) Date: 2011-12-09 16:18
Patch adapted to 3.3
History
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57776
2015-04-26 16:41:44demian.brechtsetnosy: + demian.brecht
2015-04-25 12:08:14berker.peksagsetnosy: + berker.peksag
stage: patch review

versions: + Python 3.4, Python 3.5, - Python 3.2, Python 3.3
2011-12-10 16:42:11eric.araujosetnosy: + ezio.melotti, eric.araujo

versions: - Python 2.6, Python 3.1, Python 3.4
2011-12-09 16:18:21Ketosetfiles: + httperror-geturl-fix-3.patch

messages: + msg149107
2011-12-09 15:54:42Ketocreate