diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2011-11-07 15:50:32 (GMT) |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2011-11-07 15:50:32 (GMT) |
commit | aa204dbe9c83302781f7b9d7df6db225b3661f9e (patch) | |
tree | 4414eab7cde62cafdb8b833c0c4ab5e45a7697ee /Lib/urllib | |
parent | a90e364ea5c301e76e67e23e2162f4fa8066a6f3 (diff) | |
download | cpython-aa204dbe9c83302781f7b9d7df6db225b3661f9e.zip cpython-aa204dbe9c83302781f7b9d7df6db225b3661f9e.tar.gz cpython-aa204dbe9c83302781f7b9d7df6db225b3661f9e.tar.bz2 |
Issue #13211: Add .reason attribute to HTTPError to implement parent class (URLError) interface.
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/error.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/urllib/error.py b/Lib/urllib/error.py index 300c3fe..40add41 100644 --- a/Lib/urllib/error.py +++ b/Lib/urllib/error.py @@ -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): |