1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Remove unnecessary unicode conversions from parse_kv

Fixes #8425
This commit is contained in:
James Cammarata 2014-08-04 09:43:08 -05:00
parent 642b183fb6
commit 6d94ae64ec
4 changed files with 3 additions and 4 deletions

View file

@ -31,7 +31,6 @@ import sys
import pipes import pipes
import jinja2 import jinja2
import subprocess import subprocess
import shlex
import getpass import getpass
import ansible.constants as C import ansible.constants as C

View file

@ -694,8 +694,6 @@ def parse_kv(args):
''' convert a string of key/value items to a dict ''' ''' convert a string of key/value items to a dict '''
options = {} options = {}
if args is not None: if args is not None:
# attempting to split a unicode here does bad things
args = args.encode('utf-8')
try: try:
vargs = split_args(args) vargs = split_args(args)
except ValueError, ve: except ValueError, ve:
@ -703,7 +701,6 @@ def parse_kv(args):
raise errors.AnsibleError("error parsing argument string, try quoting the entire line.") raise errors.AnsibleError("error parsing argument string, try quoting the entire line.")
else: else:
raise raise
vargs = [x.decode('utf-8') for x in vargs]
for x in vargs: for x in vargs:
if "=" in x: if "=" in x:
k, v = x.split("=",1) k, v = x.split("=",1)

View file

@ -40,3 +40,4 @@
gather_facts: true gather_facts: true
tasks: tasks:
- debug: msg='Unicode is a good thing ™' - debug: msg='Unicode is a good thing ™'
- debug: msg=АБВГД

View file

@ -165,6 +165,8 @@ class TestUtils(unittest.TestCase):
def test_parse_kv_basic(self): def test_parse_kv_basic(self):
self.assertEqual(ansible.utils.parse_kv('a=simple b="with space" c="this=that"'), self.assertEqual(ansible.utils.parse_kv('a=simple b="with space" c="this=that"'),
{'a': 'simple', 'b': 'with space', 'c': 'this=that'}) {'a': 'simple', 'b': 'with space', 'c': 'this=that'})
self.assertEqual(ansible.utils.parse_kv('msg=АБВГД'),
{'msg': 'АБВГД'})
def test_jsonify(self): def test_jsonify(self):