mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 10:51:24 -07:00
Fix log_invocation function to pass unittests on python3
Normalize this function to use native strings. Native strings won't display an extra "u" or "b" character to denote py2 unicode or py3 bytes types.
This commit is contained in:
parent
6e8e90ceb4
commit
49194a66c8
2 changed files with 1 additions and 9 deletions
|
@ -1832,14 +1832,7 @@ class AnsibleModule(object):
|
|||
param_val = param_val.encode('utf-8')
|
||||
log_args[param] = heuristic_log_sanitize(param_val, self.no_log_values)
|
||||
|
||||
msg = []
|
||||
for arg in log_args:
|
||||
arg_val = log_args[arg]
|
||||
if not isinstance(arg_val, (text_type, binary_type)):
|
||||
arg_val = str(arg_val)
|
||||
elif isinstance(arg_val, text_type):
|
||||
arg_val = arg_val.encode('utf-8')
|
||||
msg.append('%s=%s' % (arg, arg_val))
|
||||
msg = ['%s=%s' % (to_native(arg), to_native(val)) for arg, val in log_args.items()]
|
||||
if msg:
|
||||
msg = 'Invoked with %s' % ' '.join(msg)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue