New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError from HTTPError when using digest auth #59906
Comments
I attempted to connect to a site using urllib2 and digest authentication and it raised an HTTPError (due to an incorrect username and password, which is expected). I attempted to run the info() method of the HTTPError to get more information, but it failed with an AttributeError (this is the bug). $ ./reproducer.py
Traceback (most recent call last):
File "./reproducer.py", line 16, in <module>
print e.info()
File "/usr/lib/python2.6/urllib.py", line 987, in info
return self.headers
AttributeError: 'HTTPError' object has no attribute 'headers' $ python --version
Python 2.6.6 |
Python 2.6 is now in security-fix-only mode. |
Okay, this is funny. first info is invoking addinfourl of urllib, which would return headers. But in urllib2, the headers are self.hdrs I would side with the documentation that info is advertised method for HTTPError object. In 2.7, I guess just docs could be improved. This problem would be the present in 3.x. |
Even though 2.x is in security fix mode, this can be fixed by a overriding the base class's info method in the HTTPError class and returning the .hdrs attribute instead of .headers. |
New changeset ad1c1164f68b by Senthil Kumaran in branch 'default': |
New changeset 3046bfea59f3 by Senthil Kumaran in branch '2.7': New changeset 919ebf74bfdb by Senthil Kumaran in branch '3.2': New changeset a15109398294 by Senthil Kumaran in branch '3.3': |
Okay. this is fixed in all versions of python. Sorry for the delay. |
New changeset 361c10d06b9c by R David Murray in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: