mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
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:
commit
ab06e3f285
3 changed files with 87 additions and 29 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue