summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2011-11-07 15:50:32 (GMT)
committerJason R. Coombs <jaraco@jaraco.com>2011-11-07 15:50:32 (GMT)
commitaa204dbe9c83302781f7b9d7df6db225b3661f9e (patch)
tree4414eab7cde62cafdb8b833c0c4ab5e45a7697ee /Lib/urllib
parenta90e364ea5c301e76e67e23e2162f4fa8066a6f3 (diff)
downloadcpython-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.py6
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):