Synced jsonutils from oslo-incubator

The sync includes change that makes sure we get unicode-only dicts from
jsonutils no matter which json module implementation is selected.

The latest commit in oslo-incubator:
- 0f4586c0076183c6356eec682c8a593648125abd

Change-Id: Ic815ca3df94c33edec9104172048b2cd94b92e3f
Closes-Bug: 1314129
This commit is contained in:
Ihar Hrachyshka 2014-05-27 10:22:28 +02:00
parent 7a2a8b82b2
commit fe3e0f1718

View File

@ -31,6 +31,7 @@ This module provides a few things:
''' '''
import codecs
import datetime import datetime
import functools import functools
import inspect import inspect
@ -52,6 +53,7 @@ import six.moves.xmlrpc_client as xmlrpclib
from ceilometer.openstack.common import gettextutils from ceilometer.openstack.common import gettextutils
from ceilometer.openstack.common import importutils from ceilometer.openstack.common import importutils
from ceilometer.openstack.common import strutils
from ceilometer.openstack.common import timeutils from ceilometer.openstack.common import timeutils
netaddr = importutils.try_import("netaddr") netaddr = importutils.try_import("netaddr")
@ -166,12 +168,12 @@ def dumps(value, default=to_primitive, **kwargs):
return json.dumps(value, default=default, **kwargs) return json.dumps(value, default=default, **kwargs)
def loads(s): def loads(s, encoding='utf-8'):
return json.loads(s) return json.loads(strutils.safe_decode(s, encoding))
def load(s): def load(fp, encoding='utf-8'):
return json.load(s) return json.load(codecs.getreader(encoding)(fp))
try: try: