Issue #13211: Add .reason attribute to HTTPError to implement parent class (URLError) interface.

This commit is contained in:
Jason R. Coombs 2011-11-07 10:50:32 -05:00
parent a90e364ea5
commit aa204dbe9c
2 changed files with 17 additions and 0 deletions

View file

@ -52,6 +52,12 @@ class HTTPError(URLError, urllib.response.addinfourl):
def __str__(self):
return 'HTTP Error %s: %s' % (self.code, self.msg)
# since URLError specifies a .reason attribute, HTTPError should also
# provide this attribute. See issue13211 for discussion.
@property
def reason(self):
return self.msg
# exception raised when downloaded size does not match content-length
class ContentTooShortError(URLError):
def __init__(self, message, content):