From 1f4ceea069f83ed020b79cd5ebcb3f8f1b4cf123 Mon Sep 17 00:00:00 2001 From: William Douglas Date: Mon, 25 Nov 2019 10:59:31 -0800 Subject: [PATCH] Test key existance without throwing exceptions We are speculatively evaluating if a key exists, this can throw a key error exception so avoid that by using get instead. --- autospec/specfiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autospec/specfiles.py b/autospec/specfiles.py index b79c001..1b8c7df 100644 --- a/autospec/specfiles.py +++ b/autospec/specfiles.py @@ -450,7 +450,7 @@ class Specfile(object): extract_cmd = 'unzip -q {}' self._write_strip('cd %{_builddir}') archive_file = os.path.basename(archive) - if self.archive_details[archive + "prefix"]: + if self.archive_details.get(archive + "prefix"): self._write_strip(extract_cmd.format('%{_sourcedir}/' + archive_file)) else: # The archive doesn't have a prefix inside, so we have