diff options
Diffstat (limited to 'lib/ansible/utils/shlex.py')
-rw-r--r-- | lib/ansible/utils/shlex.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/ansible/utils/shlex.py b/lib/ansible/utils/shlex.py index 8f50ffd9..5e82021b 100644 --- a/lib/ansible/utils/shlex.py +++ b/lib/ansible/utils/shlex.py @@ -20,7 +20,15 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import shlex +from ansible.module_utils.six import PY3 +from ansible.module_utils._text import to_bytes, to_text -# shlex.split() wants Unicode (i.e. ``str``) input on Python 3 -shlex_split = shlex.split +if PY3: + # shlex.split() wants Unicode (i.e. ``str``) input on Python 3 + shlex_split = shlex.split +else: + # shlex.split() wants bytes (i.e. ``str``) input on Python 2 + def shlex_split(s, comments=False, posix=True): + return map(to_text, shlex.split(to_bytes(s), comments, posix)) + shlex_split.__doc__ = shlex.split.__doc__ |