Patchwork [COMMITTED,benchtests] Fix compare_strings.py for python2

login
register
mail settings
Submitter Siddhesh Poyarekar
Date Aug. 2, 2018, 6:58 p.m.
Message ID <20180802185824.14022-1-siddhesh@sourceware.org>
Download mbox | patch
Permalink /patch/28743/
State New
Headers show

Comments

Siddhesh Poyarekar - Aug. 2, 2018, 6:58 p.m.
Python 2 does not have a FileNotFoundError so drop it in favour of
simply printing out the last (and most informative) line of the
exception.

	* benchtests/scripts/compare_strings.py: Import traceback.
	(parse_file): Pretty-print error.
---
 ChangeLog                             | 3 +++
 benchtests/scripts/compare_strings.py | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

Patch

diff --git a/ChangeLog b/ChangeLog
index f77569eaff..fd47bfe5d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@ 
 2018-08-02  Siddhesh Poyarekar  <siddhesh@sourceware.org>
 
+	* benchtests/scripts/compare_strings.py: Import traceback.
+	(parse_file): Pretty-print error.
+
 	* NEWS: Mention the change.
 	* elf/dl-tunables.list: Rename tune namespace to cpu.
 	* sysdeps/powerpc/dl-tunables.list: Likewise.
diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py
index e3ad8ff058..78e508fd91 100755
--- a/benchtests/scripts/compare_strings.py
+++ b/benchtests/scripts/compare_strings.py
@@ -29,6 +29,7 @@  import os
 import json
 import pylab
 import argparse
+import traceback
 
 try:
     import jsonschema as validator
@@ -45,8 +46,8 @@  def parse_file(filename, schema_filename):
                 bench = json.load(benchfile)
                 validator.validate(bench, schema)
         return bench
-    except FileNotFoundError:
-        sys.stderr.write('Invalid input file %s.\n' % filename)
+    except:
+        print(traceback.format_exc(limit=1))
         sys.exit(os.EX_NOINPUT)
 
 def draw_graph(f, v, ifuncs, results):