Partial sync of jsonutils from openstack-common

This makes horizon work with recent versions of anyjson. Note that
there's another jsonutils change in openstack-common, but it requires
timeutils (which adds a dependency on the iso8601 module), so I skipped
it for now.

Changes from openstack-common:

    commit 4c9d439ef24f5afdd74aa9153aa8fc772051e6cb
    Author: Tim Daly Jr <timjr@yahoo-inc.com>
    Date:   Tue Jun 26 02:48:42 2012 +0000

        Add 'filedecoder' method to the jsonutils wrapper module.

        Fixes bug #1017765

        After version 3.3.2, the anyjson library will throw a KeyError if
        filedecoder isn't present.  The filedecoder is just like the decoder
        except it takes a file instead of a string, like json.load() instead
        of json.loads().

        Change-Id: I7bd012a7b4afa9b1ec987c3e6393cc922b5dadff

Change-Id: I912116d56e4e31ae93042929775c8d03dc4fa59e
This commit is contained in:
Vincent Untz 2012-07-19 11:50:39 +02:00
parent b282751440
commit f0544de692

View File

@ -130,11 +130,15 @@ def loads(s):
return json.loads(s)
def load(s):
return json.load(s)
try:
import anyjson
except ImportError:
pass
else:
anyjson._modules.append((__name__, 'dumps', TypeError,
'loads', ValueError))
'loads', ValueError, 'load'))
anyjson.force_implementation(__name__)