From a8e28a9593eda55547b4576890db50fd9cb3dc08 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Jul 03 2021 22:25:27 +0000 Subject: spectool: catch ValueError thrown by RPM for invalid .spec files Signed-off-by: Fabio Valentini --- diff --git a/rpmdev-spectool b/rpmdev-spectool index 13c1a18..1d57256 100755 --- a/rpmdev-spectool +++ b/rpmdev-spectool @@ -439,11 +439,20 @@ def main() -> int: temp.close() - spec = Spec(temp.name) - os.remove(temp.name) + try: + spec = Spec(temp.name) + except ValueError: + print("RPM Failed to parse spec file.") + return 1 + finally: + os.remove(temp.name) else: - spec = Spec(path) + try: + spec = Spec(path) + except ValueError: + print("RPM Failed to parse spec file.") + return 1 if args["list_files"] and not args["get_files"]: if args["source"]: