From 2f087859bc9539f6b86712f6c42a4500d2dad4ed Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 27 Jan 2019 01:22:14 +0000 Subject: [PATCH] issue #477: 2.4-compatible syntax. --- tests/ansible/lib/modules/mitogen_test_gethostbyname.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/ansible/lib/modules/mitogen_test_gethostbyname.py b/tests/ansible/lib/modules/mitogen_test_gethostbyname.py index f6070b03..289e9662 100644 --- a/tests/ansible/lib/modules/mitogen_test_gethostbyname.py +++ b/tests/ansible/lib/modules/mitogen_test_gethostbyname.py @@ -3,13 +3,16 @@ # I am a module that indirectly depends on glibc cached /etc/resolv.conf state. import socket +import sys + from ansible.module_utils.basic import AnsibleModule def main(): module = AnsibleModule(argument_spec={'name': {'type': 'str'}}) try: module.exit_json(addr=socket.gethostbyname(module.params['name'])) - except socket.error as e: + except socket.error: + e = sys.exc_info()[1] module.fail_json(msg=str(e)) if __name__ == '__main__':