mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Python 3: don't convert module arguments to bytes
Fixes a test failure: ====================================================================== ERROR: test_module_utils_basic_ansible_module_creation (units.module_utils.test_basic.TestModuleUtilsBasic) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/mg/src/ansible/test/units/module_utils/test_basic.py", line 250, in test_module_utils_basic_ansible_module_creation supports_check_mode=True, File "/home/mg/src/ansible/lib/ansible/module_utils/basic.py", line 470, in __init__ self._check_required_arguments() File "/home/mg/src/ansible/lib/ansible/module_utils/basic.py", line 1050, in _check_required_arguments self.fail_json(msg="missing required arguments: %s" % ",".join(missing)) File "/home/mg/src/ansible/lib/ansible/module_utils/basic.py", line 1445, in fail_json sys.exit(1) SystemExit: 1 -------------------- >> begin captured stdout << --------------------- {"msg": "missing required arguments: foo", "failed": true} because converting 'foo' to bytes yields b'foo' on Python 3, which doesn't match the native-unicode 'foo' argument spec.
This commit is contained in:
parent
ee559e03f7
commit
073f10a52a
1 changed files with 4 additions and 1 deletions
|
@ -1240,7 +1240,10 @@ class AnsibleModule(object):
|
||||||
|
|
||||||
def _load_params(self):
|
def _load_params(self):
|
||||||
''' read the input and return a dictionary and the arguments string '''
|
''' read the input and return a dictionary and the arguments string '''
|
||||||
params = json_dict_unicode_to_bytes(json.loads(MODULE_COMPLEX_ARGS))
|
params = json.loads(MODULE_COMPLEX_ARGS)
|
||||||
|
if str is bytes:
|
||||||
|
# Python 2
|
||||||
|
params = json_dict_unicode_to_bytes(params)
|
||||||
if params is None:
|
if params is None:
|
||||||
params = dict()
|
params = dict()
|
||||||
return params
|
return params
|
||||||
|
|
Loading…
Reference in a new issue