summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2024-07-25 16:05:25 +0530
committerEli Schwartz <eschwartz93@gmail.com>2024-07-25 14:57:27 -0400
commit8a202de6ec763284cbb7160b9d43d5e7e0703f19 (patch)
treedf31d277918af7ab4f65c32a3461500aea9de867
parenta544c750b1d6d6d6cd3e617da6a060f3e5662a6a (diff)
downloadmeson-8a202de6ec763284cbb7160b9d43d5e7e0703f19.tar.gz
wrap: Use OSError instead of URLError for exception handling
URLError is a subclass of OSError and intermittent server errors can manifest as OSError while reading instead of a URLError while establishing a connection, which will cause the fallback url to be ignored: ``` Looking for a fallback subproject for the dependency gudev-1.0 Downloading libgudev source from https://gitlab.gnome.org/GNOME/libgudev/-/archive/238/libgudev-238.tar.bz2 HTTP Error 404: Not Found WARNING: failed to download with error: could not get https://gitlab.gnome.org/GNOME/libgudev/-/archive/238/libgudev-238.tar.bz2 is the internet available?. Trying after a delay... HTTP Error 404: Not Found WARNING: failed to download with error: could not get https://gitlab.gnome.org/GNOME/libgudev/-/archive/238/libgudev-238.tar.bz2 is the internet available?. Trying after a delay... HTTP Error 404: Not Found WARNING: failed to download with error: could not get https://gitlab.gnome.org/GNOME/libgudev/-/archive/238/libgudev-238.tar.bz2 is the internet available?. Trying after a delay... WARNING: failed to download with error: The read operation timed out. Trying after a delay... WARNING: failed to download with error: The read operation timed out. Trying after a delay... ERROR: Unhandled python OSError. This is probably not a Meson bug, but an issue with your build environment. ```
-rw-r--r--mesonbuild/wrap/wrap.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index 4e98c600c..3fe40ed9f 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -76,9 +76,9 @@ def open_wrapdburl(urlstring: str, allow_insecure: bool = False, have_opt: bool
if has_ssl:
try:
return T.cast('http.client.HTTPResponse', urllib.request.urlopen(urllib.parse.urlunparse(url), timeout=REQ_TIMEOUT))
- except urllib.error.URLError as excp:
+ except OSError as excp:
msg = f'WrapDB connection failed to {urlstring} with error {excp}.'
- if isinstance(excp.reason, ssl.SSLCertVerificationError):
+ if isinstance(excp, urllib.error.URLError) and isinstance(excp.reason, ssl.SSLCertVerificationError):
if allow_insecure:
mlog.warning(f'{msg}\n\n Proceeding without authentication.')
else:
@@ -95,7 +95,7 @@ def open_wrapdburl(urlstring: str, allow_insecure: bool = False, have_opt: bool
nossl_url = url._replace(scheme='http')
try:
return T.cast('http.client.HTTPResponse', urllib.request.urlopen(urllib.parse.urlunparse(nossl_url), timeout=REQ_TIMEOUT))
- except urllib.error.URLError as excp:
+ except OSError as excp:
raise WrapException(f'WrapDB connection failed to {urlstring} with error {excp}')
def get_releases_data(allow_insecure: bool) -> bytes:
@@ -704,7 +704,7 @@ class Resolver:
try:
req = urllib.request.Request(urlstring, headers=headers)
resp = urllib.request.urlopen(req, timeout=REQ_TIMEOUT)
- except urllib.error.URLError as e:
+ except OSError as e:
mlog.log(str(e))
raise WrapException(f'could not get {urlstring} is the internet available?')
with contextlib.closing(resp) as resp, tmpfile as tmpfile: