diff --git a/hacking/test-module b/hacking/test-module index bc18420183..89413c8b4b 100755 --- a/hacking/test-module +++ b/hacking/test-module @@ -42,6 +42,7 @@ from ansible.parsing.utils.jsonify import jsonify from ansible.parsing.splitter import parse_kv import ansible.executor.module_common as module_common import ansible.constants as C +from ansible.module_utils._text import to_text try: import json @@ -159,7 +160,7 @@ def boilerplate_module(modfile, args, interpreters, check, destfile): print("* including generated source, if any, saving to: %s" % modfile2_path) if module_style not in ('ansiballz', 'old'): print("* this may offset any line numbers in tracebacks/debuggers!") - modfile2 = open(modfile2_path, 'w') + modfile2 = open(modfile2_path, 'wb') modfile2.write(module_data) modfile2.close() modfile = modfile2_path @@ -178,6 +179,7 @@ def ansiballz_setup(modfile, modname, interpreters): cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = cmd.communicate() + out, err = to_text(out, errors='surrogate_or_strict'), to_text(err) lines = out.splitlines() if len(lines) != 2 or 'Module expanded into' not in lines[0]: print("*" * 35) @@ -209,6 +211,7 @@ def runtest(modfile, argspath, modname, module_style, interpreters): cmd = subprocess.Popen(invoke, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = cmd.communicate() + out, err = to_text(out), to_text(err) try: print("*" * 35)