mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
Workaround more python-2.6 shlex not being able to handle unicode strings
This commit is contained in:
parent
a6029264b8
commit
a10d10f647
4 changed files with 32 additions and 22 deletions
|
@ -151,11 +151,18 @@ class ModuleReplacer(object):
|
|||
complex_args_json = utils.jsonify(complex_args)
|
||||
# We force conversion of module_args to str because module_common calls shlex.split,
|
||||
# a standard library function that incorrectly handles Unicode input before Python 2.7.3.
|
||||
# Note: it would be better to do all this conversion at the border
|
||||
# (when the data is originally parsed into data structures) but
|
||||
# it's currently coming from too many sources to make that
|
||||
# effective.
|
||||
try:
|
||||
encoded_args = repr(module_args.encode('utf-8'))
|
||||
except UnicodeDecodeError:
|
||||
encoded_args = repr(module_args)
|
||||
encoded_complex = repr(complex_args_json)
|
||||
try:
|
||||
encoded_complex = repr(complex_args_json.encode('utf-8'))
|
||||
except UnicodeDecodeError:
|
||||
encoded_complex = repr(complex_args_json.encode('utf-8'))
|
||||
|
||||
# these strings should be part of the 'basic' snippet which is required to be included
|
||||
module_data = module_data.replace(REPLACER_VERSION, repr(__version__))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue