mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
Fix issue 10817 - Fix urlretrieve function to raise ContentTooShortError
even when reporthook is None. Patch by Jyrki Pulliainen.
This commit is contained in:
parent
53bcd66012
commit
ce260142c6
3 changed files with 87 additions and 29 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue