diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2011-10-31 17:39:49 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2011-10-31 17:39:49 (GMT) |
commit | ab06e3f285ae61e5abc48b350034c94b7d624fda (patch) | |
tree | 9325164c48c71835018d81d4490bd8b91800ad1a /Lib/urllib | |
parent | 6a57afee04ad569a274880b526d39954d06ef53e (diff) | |
parent | ce260142c6c6eaf32775c4aec283c3a4c921b75c (diff) | |
download | cpython-ab06e3f285ae61e5abc48b350034c94b7d624fda.zip cpython-ab06e3f285ae61e5abc48b350034c94b7d624fda.tar.gz cpython-ab06e3f285ae61e5abc48b350034c94b7d624fda.tar.bz2 |
merge from 3.2 - Fix issue 10817 - Fix urlretrieve function to raise ContentTooShortError
even when reporthook is None. Patch by Jyrki Pulliainen.
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 71011bd..9a0ab60 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -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) |