pythondistdeps.py: Catch all exceptions and terminate build if one is raised

This commit is contained in:
Tomas Orsava 2021-05-25 17:56:00 +02:00
parent 27d363833e
commit cc489bde7a
2 changed files with 19 additions and 4 deletions

View File

@ -1,7 +1,7 @@
Name: python-rpm-generators
Summary: Dependency generators for Python RPMs
Version: 12
Release: 6%{?dist}
Release: 7%{?dist}
# Originally all those files were part of RPM, so license is kept here
License: GPLv2+
@ -47,6 +47,10 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py
%{_rpmconfigdir}/pythonbundles.py
%changelog
* Tue May 25 2021 Tomas Orsava <torsava@redhat.com> - 12-7
- pythondistdeps.py: Detect missing or corrupted metadata
- pythondistdeps.py: Catch all exceptions and terminate the build if one is raised
* Mon Apr 19 2021 Miro Hrončok <mhroncok@redhat.com> - 12-6
- Get rid of distutils deprecation warning (by not using it)
- The distutils module is deprecated in Python 3.10+

View File

@ -260,10 +260,10 @@ def get_marker_env(dist, extra):
"extra": extra}
if __name__ == "__main__":
def main():
"""To allow this script to be importable (and its classes/functions
reused), actions are performed only when run as a main script."""
reused), actions are defined in the main function and are performed only
when run as a main script."""
parser = argparse.ArgumentParser(prog=argv[0])
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-P', '--provides', action='store_true', help='Print Provides')
@ -552,3 +552,14 @@ if __name__ == "__main__":
else:
# Print out unversioned provides, requires, recommends, conflicts
print(name)
if __name__ == "__main__":
"""To allow this script to be importable (and its classes/functions
reused), actions are performed only when run as a main script."""
try:
main()
except Exception as exc:
print("*** PYTHONDISTDEPS_GENERATORS_FAILED ***", flush=True)
raise RuntimeError("Error: pythondistdeps.py generator encountered an unhandled exception and was terminated.") from exc