Fix issue 10817 - Fix urlretrieve function to raise ContentTooShortError

even when reporthook is None. Patch by Jyrki Pulliainen.
This commit is contained in:
Senthil Kumaran 2011-11-01 01:35:17 +08:00
parent 53bcd66012
commit ce260142c6
3 changed files with 87 additions and 29 deletions

View file

@ -1589,9 +1589,9 @@ class URLopener:
size = -1
read = 0
blocknum = 0
if "content-length" in headers:
size = int(headers["Content-Length"])
if reporthook:
if "content-length" in headers:
size = int(headers["Content-Length"])
reporthook(blocknum, bs, size)
while 1:
block = fp.read(bs)