summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorFacundo Batista <facundo@taniquetil.com.ar>2015-04-22 21:35:54 (GMT)
committerFacundo Batista <facundo@taniquetil.com.ar>2015-04-22 21:35:54 (GMT)
commit244afcf26cfd32deb6d389c4f1358ae16303affb (patch)
treee99593970ecdf7979618e3d0f0d3cad28c7c4700 /Lib/urllib
parentd209d646c996a9e990d8fd1466405d448bbfdb6d (diff)
downloadcpython-244afcf26cfd32deb6d389c4f1358ae16303affb.zip
cpython-244afcf26cfd32deb6d389c4f1358ae16303affb.tar.gz
cpython-244afcf26cfd32deb6d389c4f1358ae16303affb.tar.bz2
Issue #23887: urllib.error.HTTPError now has a proper repr() representation.
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/error.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/urllib/error.py b/Lib/urllib/error.py
index 45b7169..c5b675d 100644
--- a/Lib/urllib/error.py
+++ b/Lib/urllib/error.py
@@ -35,6 +35,7 @@ class URLError(OSError):
def __str__(self):
return '<urlopen error %s>' % self.reason
+
class HTTPError(URLError, urllib.response.addinfourl):
"""Raised when HTTP error occurs, but also acts like non-error return"""
__super_init = urllib.response.addinfourl.__init__
@@ -55,6 +56,9 @@ class HTTPError(URLError, urllib.response.addinfourl):
def __str__(self):
return 'HTTP Error %s: %s' % (self.code, self.msg)
+ def __repr__(self):
+ return '<HTTPError %s: %r>' % (self.code, self.msg)
+
# since URLError specifies a .reason attribute, HTTPError should also
# provide this attribute. See issue13211 for discussion.
@property
@@ -69,8 +73,9 @@ class HTTPError(URLError, urllib.response.addinfourl):
def headers(self, headers):
self.hdrs = headers
-# exception raised when downloaded size does not match content-length
+
class ContentTooShortError(URLError):
+ """Exception raised when downloaded size does not match content-length."""
def __init__(self, message, content):
URLError.__init__(self, message)
self.content = content