Issue #13211: Add .reason attribute to HTTPError to implement parent class (URLError) interface.
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index a0065b5..5471acd 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -166,6 +166,12 @@
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 fo discussion.
+ @property
+ def reason(self):
+ return self.msg
+
# copied from cookielib.py
_cut_port_re = re.compile(r":\d+$")
def request_host(request):