From 7e54c9a46879195038e35dc2b09294e8254aee68 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 25 Jul 2016 11:16:27 -0700 Subject: [PATCH] No longer try to import __version__ from release.py. (#16817) I'm not sure why that would be desirable -- we really want __version__ to come from the controller whereas importing will come from the client node. If it turns out there was a reason to do that, please be sure to use an exception handler that catches all exceptions instead of only catching ImportError: ``` try: from ansible.release import __version__, __author__ except: __version__ = [...] ``` Fixes #16523 --- lib/ansible/executor/module_common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/executor/module_common.py b/lib/ansible/executor/module_common.py index 35dfd68abd8..23954a3e91b 100644 --- a/lib/ansible/executor/module_common.py +++ b/lib/ansible/executor/module_common.py @@ -596,7 +596,9 @@ def _find_snippet_imports(module_name, module_data, module_path, module_args, ta # Create the module zip data zipoutput = BytesIO() zf = zipfile.ZipFile(zipoutput, mode='w', compression=compression_method) - zf.writestr('ansible/__init__.py', b'from pkgutil import extend_path\n__path__=extend_path(__path__,__name__)\ntry:\n from ansible.release import __version__,__author__\nexcept ImportError:\n __version__="' + to_bytes(__version__) + b'"\n __author__="' + to_bytes(__author__) + b'"\n') + ### Note: If we need to import from release.py first, + ### remember to catch all exceptions: https://github.com/ansible/ansible/issues/16523 + zf.writestr('ansible/__init__.py', b'from pkgutil import extend_path\n__path__=extend_path(__path__,__name__)\n__version__="' + to_bytes(__version__) + b'"\n__author__="' + to_bytes(__author__) + b'"\n') zf.writestr('ansible/module_utils/__init__.py', b'from pkgutil import extend_path\n__path__=extend_path(__path__,__name__)\n') zf.writestr('ansible_module_%s.py' % module_name, module_data)