Repository: mesonbuild/meson

Issue:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
```
Dowloading json from https://github.com/nlohmann/json/archive/v2.0.3.tar.gz
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 283, in run
    app.generate()
  File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 166, in generate
    intr.run()
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1154, in run
    self.evaluate_codeblock(self.ast)
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1176, in evaluate_codeblock
    raise e
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1170, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1293, in evaluate_statement
    return self.assignment(cur)
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2208, in assignment
    value = self.evaluate_statement(node.value)
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1291, in evaluate_statement
    return self.function_call(cur)
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 2189, in function_call
    return self.funcs[func_name](node, self.flatten(posargs), kwargs)
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 73, in wrapped
    return f(self, node, args, kwargs)
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1374, in func_subproject
    return self.do_subproject(dirname, kwargs)
  File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1388, in do_subproject
    resolved = r.resolve(dirname)
  File "/usr/lib/python3.5/site-packages/mesonbuild/wrap/wrap.py", line 103, in resolve
    self.download(p, packagename)
  File "/usr/lib/python3.5/site-packages/mesonbuild/wrap/wrap.py", line 172, in download
    srcdata = self.get_data(srcurl)
  File "/usr/lib/python3.5/site-packages/mesonbuild/wrap/wrap.py", line 137, in get_data
    dlsize = int(resp.info()['Content-Length'])
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
+ ninja
ninja: error: loading 'build.ninja': No such file or directory
+ ninja
ninja: error: loading 'build.ninja': No such file or directory
```



Discussion:
Has happened several times on local dev and on CI too. 


Resolving patch:
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -139,7 +139,13 @@ def get_data(self, url):
         else:
             resp = urllib.request.urlopen(url)
         with contextlib.closing(resp) as resp:
-            dlsize = int(resp.info()['Content-Length'])
+            try:
+                dlsize = int(resp.info()['Content-Length'])
+            except TypeError:
+                dlsize = None
+            if dlsize is None:
+                print('Downloading file of unknown size.')
+                return resp.read()
             print('Download size:', dlsize)
             print('Downloading: ', end='')
             sys.stdout.flush()


Test patch: