Fix Unicode error printing extra-specs
If type-key is set to unicode the command cinder extra-specs-list fails with the ERROR: 'ascii' codec can't encode characters in position. This patch fixes it. Change-Id: Id82bfbe8870351605f53c7ca029b9aa7e6089f6a Closes-Bug: #1568937
This commit is contained in:
@@ -228,6 +228,10 @@ class PrintListTestCase(test_utils.TestCase):
|
|||||||
+---+-----+
|
+---+-----+
|
||||||
""", cso.read())
|
""", cso.read())
|
||||||
|
|
||||||
|
def test_unicode_key_value_to_string(self):
|
||||||
|
expected = {u'key': u'\u043f\u043f\u043f\u043f\u043f'}
|
||||||
|
self.assertEqual(expected, utils.unicode_key_value_to_string(expected))
|
||||||
|
|
||||||
|
|
||||||
class PrintDictTestCase(test_utils.TestCase):
|
class PrintDictTestCase(test_utils.TestCase):
|
||||||
|
|
||||||
|
@@ -182,8 +182,9 @@ def unicode_key_value_to_string(dictionary):
|
|||||||
"""Recursively converts dictionary keys to strings."""
|
"""Recursively converts dictionary keys to strings."""
|
||||||
if not isinstance(dictionary, dict):
|
if not isinstance(dictionary, dict):
|
||||||
return dictionary
|
return dictionary
|
||||||
return dict((str(k), str(unicode_key_value_to_string(v)))
|
return dict((six.text_type(k),
|
||||||
for k, v in dictionary.items())
|
six.text_type(unicode_key_value_to_string(v)))
|
||||||
|
for k, v in dictionary.items())
|
||||||
|
|
||||||
|
|
||||||
def print_dict(d, property="Property", formatters=None):
|
def print_dict(d, property="Property", formatters=None):
|
||||||
|
Reference in New Issue
Block a user