From 54e4c53f00d1dcc82b8e24497a686d31bb265b45 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 8 Aug 2018 14:29:14 -0500 Subject: [PATCH] Ensure removed_in is StrictVersion before comparing (#43835) * Ensure removed_in is StrictVersion before comparing * Catch ValueError with StrictVersion on incompatible versions --- test/sanity/validate-modules/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/sanity/validate-modules/main.py b/test/sanity/validate-modules/main.py index 4f800e50e6..32f34fedb0 100755 --- a/test/sanity/validate-modules/main.py +++ b/test/sanity/validate-modules/main.py @@ -1374,10 +1374,14 @@ class ModuleValidator(Validator): # See if current version => deprecated.removed_in, ie, should be docs only if docs and 'deprecated' in docs and docs['deprecated'] is not None: - removed_in = docs.get('deprecated')['removed_in'] - strict_ansible_version = StrictVersion('.'.join(ansible_version.split('.')[:2])) - end_of_deprecation_should_be_docs_only = strict_ansible_version >= removed_in - # FIXME if +2 then file should be empty? - maybe add this only in the future + try: + removed_in = StrictVersion(str(docs.get('deprecated')['removed_in'])) + except ValueError: + end_of_deprecation_should_be_docs_only = False + else: + strict_ansible_version = StrictVersion('.'.join(ansible_version.split('.')[:2])) + end_of_deprecation_should_be_docs_only = strict_ansible_version >= removed_in + # FIXME if +2 then file should be empty? - maybe add this only in the future if self._python_module() and not self._just_docs() and not end_of_deprecation_should_be_docs_only: self._validate_ansible_module_call(docs)