[New-bugs-announce] [issue13567] HTTPError interface changes / breaks depending on what was passed to constructor
report at bugs.python.org
Fri Dec 9 16:54:42 CET 2011
New submission from Pami Ketolainen <pami.ketolainen at gmail.com>:
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.
components: Library (Lib)
title: HTTPError interface changes / breaks depending on what was passed to constructor
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file23892/httperror-geturl-fix-2.patch
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce