From 70a063a3b9a32e16b4278b49e1e236c9ad91fc76 Mon Sep 17 00:00:00 2001 From: David Culley <6276049+davidculley@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:17:37 +0200 Subject: [PATCH] Fix error if regex can't find the filename (#3285) * fix: treat error if regex doesn't match * refactor: use assertion to avoid error message --- qt/aqt/addons.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qt/aqt/addons.py b/qt/aqt/addons.py index c6181ef0a..890c10c2a 100644 --- a/qt/aqt/addons.py +++ b/qt/aqt/addons.py @@ -1086,9 +1086,11 @@ def download_addon(client: HttpClient, id: int) -> DownloadOk | DownloadError: data = client.stream_content(resp) - fname = re.match( + match = re.match( "attachment; filename=(.+)", resp.headers["content-disposition"] - ).group(1) + ) + assert match is not None + fname = match.group(1) meta = extract_meta_from_download_url(resp.url)