merge from 3.2 - 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:39:49 +08:00
commit ab06e3f285
3 changed files with 87 additions and 29 deletions

View file

@ -1605,9 +1605,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)