Merge pull request #35 from kiwix/no_context_old_python
Use the `urllib.request.urlopen`'s `context` argument only if available.
This commit is contained in:
commit
a66dfecc31
|
@ -419,7 +419,8 @@ class BuildEnv:
|
||||||
else:
|
else:
|
||||||
context = None
|
context = None
|
||||||
batch_size = 1024 * 8
|
batch_size = 1024 * 8
|
||||||
with urllib.request.urlopen(file_url, context=context) as resource, open(file_path, 'wb') as file:
|
extra_args = {'context':context} if sys.version_info >= (3, 4, 3) else {}
|
||||||
|
with urllib.request.urlopen(file_url, **extra_args) as resource, open(file_path, 'wb') as file:
|
||||||
while True:
|
while True:
|
||||||
batch = resource.read(batch_size)
|
batch = resource.read(batch_size)
|
||||||
if not batch:
|
if not batch:
|
||||||
|
|
Loading…
Reference in New Issue