From bcfd5560427a6abf737806ffdad6faadc7a2651b Mon Sep 17 00:00:00 2001 From: Michel Alexandre Salim Date: Jul 14 2022 21:17:35 +0000 Subject: gpgverify check should handle missing %prep Having a `%prep` section is not mandatory (it generates an rpmlint warning, not error), but not having it causes the gpgverify SHOULD plugin to fail as it assumes the section exists. Handle this by using `or []` before iterating over the section's lines, as `get_section` returns `None` on non-existent sections. Fixes #448. Signed-off-by: Michel Alexandre Salim --- diff --git a/plugins/generic_should.py b/plugins/generic_should.py index 4bba072..5ae14c5 100644 --- a/plugins/generic_should.py +++ b/plugins/generic_should.py @@ -581,7 +581,7 @@ class CheckSourceVerification(GenericShouldCheckBase): other_before = False command_pattern = re.compile(r"/gpgverify ") comment_pattern = re.compile(r"^[ \t]*#") - for line in self.spec.get_section("prep"): + for line in self.spec.get_section("prep") or []: if comment_pattern.match(line) is None: if command_pattern.search(line) is None: other_seen = True