Check reporthook is not None before calling it
@@ -57,6 +57,7 @@ if sys.version_info[0] == 2:
chunk = response.read(chunk_size)
count += 1
if not chunk:
+ if reporthook:
reporthook(count, total_size, total_size)
break
if reporthook:
