From 3d6fc9e2b9df77c2ae9df0ff6a667f219ed5d1b0 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 27 Oct 2017 22:12:28 +0200 Subject: [PATCH] Catch specific exceptions in python scripts. --- tools/sg_xml_unit_converter.py | 4 ++-- tools/tesh/tesh.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/sg_xml_unit_converter.py b/tools/sg_xml_unit_converter.py index ff81d66575..ce75e53d41 100644 --- a/tools/sg_xml_unit_converter.py +++ b/tools/sg_xml_unit_converter.py @@ -12,7 +12,7 @@ import sys import fnmatch import os -from decimal import Decimal +from decimal import Decimal, DecimalException import re @@ -37,7 +37,7 @@ def format(xml, formats, attrib): tmp = "%s%s" % (to_str(d), f) break res.append(tmp) - except: + except DecimalException: print "Error with:", val res.append(val) m = re.search(r'%s="(.*?)"' % attrib, xml) diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index c9cd570987..1faee7f4f9 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -410,7 +410,7 @@ if __name__ == '__main__': try: options = parser.parse_args() - except: + except SystemExit: tesh_exit(1) if options.cd is not None: -- 2.20.1