wrap: ensure the tempfile used for downloading is closed

This is generally a good idea, and the tempfile is already instructed to
not auto-delete on close. It also fixes a bug on PyPy, where the file
isn't valid because it's not explicitly closed. This is probably due to
the garbage collection modes -- in CPython, the object goes out of scope
and gets automatically closed before we actually attempt to unpack it.

Fixes #11246
pull/11391/head
Eli Schwartz 2 years ago committed by Xavier Claessens
parent e0b63d539e
commit 7ab2892eb0
  1. 2
      mesonbuild/wrap/wrap.py

@ -676,7 +676,7 @@ class Resolver:
except urllib.error.URLError as e:
mlog.log(str(e))
raise WrapException(f'could not get {urlstring} is the internet available?')
with contextlib.closing(resp) as resp:
with contextlib.closing(resp) as resp, tmpfile as tmpfile:
try:
dlsize = int(resp.info()['Content-Length'])
except TypeError:

Loading…
Cancel
Save