From 7eb38208af73fe1cce511844006f58ed87e69fed Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 27 May 2014 10:22:28 +0200 Subject: [PATCH] Synced jsonutils from oslo-incubator The sync includes change that drastically enhances performance on Python 2.6 with fresh simplejson library installed. The latest commit in oslo-incubator: - 0f4586c0076183c6356eec682c8a593648125abd The following changes are included with this patch: -> 18f2bc1 Enforce unicode json output for jsonutils.load[s]() --> cinder/openstack/common/jsonutils.py Change-Id: Ib3dc0b713ed90396919feba018772243b3b9c90f Closes-Bug: 1314129 --- cinder/openstack/common/jsonutils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cinder/openstack/common/jsonutils.py b/cinder/openstack/common/jsonutils.py index 733baef57..0aaa138db 100644 --- a/cinder/openstack/common/jsonutils.py +++ b/cinder/openstack/common/jsonutils.py @@ -31,6 +31,7 @@ This module provides a few things: ''' +import codecs import datetime import functools import inspect @@ -52,6 +53,7 @@ import six.moves.xmlrpc_client as xmlrpclib from cinder.openstack.common import gettextutils from cinder.openstack.common import importutils +from cinder.openstack.common import strutils from cinder.openstack.common import timeutils netaddr = importutils.try_import("netaddr") @@ -166,12 +168,12 @@ def dumps(value, default=to_primitive, **kwargs): return json.dumps(value, default=default, **kwargs) -def loads(s): - return json.loads(s) +def loads(s, encoding='utf-8'): + return json.loads(strutils.safe_decode(s, encoding)) -def load(fp): - return json.load(fp) +def load(fp, encoding='utf-8'): + return json.load(codecs.getreader(encoding)(fp)) try: -- 2.45.2