From f7bfa96caf828273a5c46a7f1ac728509c8a77fc Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Sat, 5 Aug 2017 22:16:10 -0700 Subject: [PATCH] Use 0 instead of None for line and offset. --- test/runner/importer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/runner/importer.py b/test/runner/importer.py index f678052c81..35685f5ed6 100755 --- a/test/runner/importer.py +++ b/test/runner/importer.py @@ -29,22 +29,22 @@ def main(): for result in results: if result[0].startswith(base_dir): source = result[0][len(base_dir) + 1:].replace('test/runner/import/', '') - line = result[1] + line = result[1] or 0 break if not source: # If none of our source files are found in the traceback, report the file we were testing. # I haven't been able to come up with a test case that encounters this issue yet. source = path - message += ' (in %s:%d)' % (results[-1][0], results[-1][1]) + message += ' (in %s:%d)' % (results[-1][0], results[-1][1] or 0) elif isinstance(ex, SyntaxError): if ex.filename.endswith(path): # pylint: disable=locally-disabled, no-member # A SyntaxError in the source we're importing will have the correct path, line and offset. # However, the traceback will report the path to this importer.py script instead. # We'll use the details from the SyntaxError in this case, as it's more accurate. source = path - line = ex.lineno # pylint: disable=locally-disabled, no-member - offset = ex.offset # pylint: disable=locally-disabled, no-member + line = ex.lineno or 0 # pylint: disable=locally-disabled, no-member + offset = ex.offset or 0 # pylint: disable=locally-disabled, no-member message = str(ex) # Hack to remove the filename and line number from the message, if present.