summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-03-02 22:50:25 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-03-02 22:50:25 (GMT)
commit6accb988a1822dc2927346ae4819aff8cc876b98 (patch)
tree42eaf66c7e2c74ae8dead53d95dcd812df7e318a /Lib/http
parenta4f52b12d6e401f14f3c8e9e2d533eb448388bcc (diff)
downloadcpython-6accb988a1822dc2927346ae4819aff8cc876b98.zip
cpython-6accb988a1822dc2927346ae4819aff8cc876b98.tar.gz
cpython-6accb988a1822dc2927346ae4819aff8cc876b98.tar.bz2
Merged revisions 70107 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70107 | benjamin.peterson | 2009-03-02 16:41:42 -0600 (Mon, 02 Mar 2009) | 1 line give httplib.IncompleteRead a more sane repr #4308 ........
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/client.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py
index 14a6c35..b1b76c2 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -578,7 +578,7 @@ class HTTPResponse(io.RawIOBase):
while amt > 0:
chunk = self.fp.read(min(amt, MAXAMOUNT))
if not chunk:
- raise IncompleteRead(s)
+ raise IncompleteRead(b''.join(s), amt)
s.append(chunk)
amt -= len(chunk)
return b"".join(s)
@@ -1009,9 +1009,18 @@ class UnimplementedFileMode(HTTPException):
pass
class IncompleteRead(HTTPException):
- def __init__(self, partial):
+ def __init__(self, partial, expected=None):
self.args = partial,
self.partial = partial
+ self.expected = expected
+ def __repr__(self):
+ if self.expected is not None:
+ e = ', %i more expected' % self.expected
+ else:
+ e = ''
+ return 'IncompleteRead(%i bytes read%s)' % (len(self.partial), e)
+ def __str__(self):
+ return repr(self)
class ImproperConnectionState(HTTPException):
pass