summaryrefslogtreecommitdiffstats
path: root/openstack/common/jsonutils.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-05-07 12:50:02 +0000
committerGerrit Code Review <review@openstack.org>2013-05-07 12:50:02 +0000
commit6a4800d8cc36812835dca796895bafec940b2ce5 (patch)
treecb8eedc9470e2a68d86a4863ddf98d200edb093d /openstack/common/jsonutils.py
parentf9d502228752bcb909e58cafacd1cd948d9a8206 (diff)
parentfde1e156a38633ce9018569145390bce2047fea8 (diff)
downloadoslo-6a4800d8cc36812835dca796895bafec940b2ce5.tar.gz
oslo-6a4800d8cc36812835dca796895bafec940b2ce5.tar.xz
oslo-6a4800d8cc36812835dca796895bafec940b2ce5.zip
Merge "Convert unicode for python3 portability"
Diffstat (limited to 'openstack/common/jsonutils.py')
-rw-r--r--openstack/common/jsonutils.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/openstack/common/jsonutils.py b/openstack/common/jsonutils.py
index f3cc0e9..bf23403 100644
--- a/openstack/common/jsonutils.py
+++ b/openstack/common/jsonutils.py
@@ -41,6 +41,8 @@ import json
import types
import xmlrpclib
+import six
+
from openstack.common import timeutils
@@ -93,7 +95,7 @@ def to_primitive(value, convert_instances=False, convert_datetime=True,
# value of itertools.count doesn't get caught by nasty_type_tests
# and results in infinite loop when list(value) is called.
if type(value) == itertools.count:
- return unicode(value)
+ return six.text_type(value)
# FIXME(vish): Workaround for LP bug 852095. Without this workaround,
# tests that raise an exception in a mocked method that
@@ -137,12 +139,12 @@ def to_primitive(value, convert_instances=False, convert_datetime=True,
return recursive(value.__dict__, level=level + 1)
else:
if any(test(value) for test in _nasty_type_tests):
- return unicode(value)
+ return six.text_type(value)
return value
except TypeError:
# Class objects are tricky since they may define something like
# __iter__ defined but it isn't callable as list().
- return unicode(value)
+ return six.text_type(value)
def dumps(value, default=to_primitive, **kwargs):