summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2022-04-07 06:45:08 -0700
committerGitHub <noreply@github.com>2022-04-07 08:45:08 -0500
commit3b20b02272189c21fc2a0cccdab89c9c94e1fe98 (patch)
tree1074fd598b25ecd48c708bf662ffc5bfea66d17b
parent6b6b3246180a79d1eacafd9da126ceb825be2466 (diff)
downloadansible-3b20b02272189c21fc2a0cccdab89c9c94e1fe98.tar.gz
[stable-2.13] Fix sanity test crash. (#77475)
(cherry picked from commit 6216c9fc93cb29283f6eb6d15561762eeb2c7b2e) Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
-rw-r--r--changelogs/fragments/77465-ansible-test-compile-crash.yml2
-rw-r--r--test/lib/ansible_test/_util/target/sanity/compile/compile.py4
2 files changed, 6 insertions, 0 deletions
diff --git a/changelogs/fragments/77465-ansible-test-compile-crash.yml b/changelogs/fragments/77465-ansible-test-compile-crash.yml
new file mode 100644
index 0000000000..795f908d87
--- /dev/null
+++ b/changelogs/fragments/77465-ansible-test-compile-crash.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - "ansible-test compile sanity test - do not crash if a column could not be determined for an error (https://github.com/ansible/ansible/pull/77465)."
diff --git a/test/lib/ansible_test/_util/target/sanity/compile/compile.py b/test/lib/ansible_test/_util/target/sanity/compile/compile.py
index e2302fc0e7..7890a9b2aa 100644
--- a/test/lib/ansible_test/_util/target/sanity/compile/compile.py
+++ b/test/lib/ansible_test/_util/target/sanity/compile/compile.py
@@ -24,6 +24,10 @@ def main():
else:
continue
+ # In some situations offset can be None. This can happen for syntax errors on Python 2.6
+ # (__future__ import following after a regular import).
+ offset = offset or 0
+
result = "%s:%d:%d: %s: %s" % (path, lineno, offset, extype.__name__, safe_message(message))
if sys.version_info <= (3,):