mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Use 0 instead of None for line and offset.
This commit is contained in:
parent
af9b0ba47b
commit
f7bfa96caf
1 changed files with 4 additions and 4 deletions
|
@ -29,22 +29,22 @@ def main():
|
||||||
for result in results:
|
for result in results:
|
||||||
if result[0].startswith(base_dir):
|
if result[0].startswith(base_dir):
|
||||||
source = result[0][len(base_dir) + 1:].replace('test/runner/import/', '')
|
source = result[0][len(base_dir) + 1:].replace('test/runner/import/', '')
|
||||||
line = result[1]
|
line = result[1] or 0
|
||||||
break
|
break
|
||||||
|
|
||||||
if not source:
|
if not source:
|
||||||
# If none of our source files are found in the traceback, report the file we were testing.
|
# 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.
|
# I haven't been able to come up with a test case that encounters this issue yet.
|
||||||
source = path
|
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):
|
elif isinstance(ex, SyntaxError):
|
||||||
if ex.filename.endswith(path): # pylint: disable=locally-disabled, no-member
|
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.
|
# 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.
|
# 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.
|
# We'll use the details from the SyntaxError in this case, as it's more accurate.
|
||||||
source = path
|
source = path
|
||||||
line = ex.lineno # pylint: disable=locally-disabled, no-member
|
line = ex.lineno or 0 # pylint: disable=locally-disabled, no-member
|
||||||
offset = ex.offset # pylint: disable=locally-disabled, no-member
|
offset = ex.offset or 0 # pylint: disable=locally-disabled, no-member
|
||||||
message = str(ex)
|
message = str(ex)
|
||||||
|
|
||||||
# Hack to remove the filename and line number from the message, if present.
|
# Hack to remove the filename and line number from the message, if present.
|
||||||
|
|
Loading…
Reference in a new issue