Fix -vvvvv unicode error in executor.module_common (#70368)

Change:
- Fix a UnicodeDecodeError in executor.module_common that could get
  triggered with -vvvvv.

Test Plan:
- `ansible-test integration --docker centos7 module_utils -vvvvv`
  This would show the error previously, and no loner does after this
  patch.

Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
Rick Elrod 2020-06-29 18:02:03 -05:00 committed by GitHub
parent 70bb2b33ca
commit cc2cee6980
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -904,7 +904,8 @@ def recursive_finder(name, module_fqn, data, py_module_names, py_module_cache, z
py_module_file_name = '%s.py' % py_module_path
zf.writestr(py_module_file_name, py_module_cache[py_module_name][0])
display.vvvvv("Using module_utils file %s" % py_module_cache[py_module_name][1])
mu_file = to_text(py_module_cache[py_module_name][1], errors='surrogate_or_strict')
display.vvvvv("Using module_utils file %s" % mu_file)
# Add the names of the files we're scheduling to examine in the loop to
# py_module_names so that we don't re-examine them in the next pass

View file

@ -0,0 +1,5 @@
- hosts: testhost
gather_facts: no
tasks:
- name: Use a specially crafted module to see if things were imported correctly
test:

View file

@ -4,5 +4,10 @@ set -eux
ANSIBLE_ROLES_PATH=../ ansible-playbook module_utils_basic_setcwd.yml -i ../../inventory "$@"
# Keep the -vvvvv here. This acts as a test for testing that higher verbosity
# doesn't traceback with unicode in the custom module_utils directory path.
ansible-playbook module_utils_vvvvv.yml -i ../../inventory -vvvvv "$@"
ansible-playbook module_utils_test.yml -i ../../inventory -v "$@"
ANSIBLE_MODULE_UTILS=other_mu_dir ansible-playbook module_utils_envvar.yml -i ../../inventory -v "$@"