Remove fallback to simplejson in jsonutils
OpenStack has ended support for Python 2.6 in all services and libraries. We no longer need to support a fallback to simplejson on Python 2.6 so we can remove this fallback logic. Closes-bug: 1533337 Change-Id: I613541a37229ff2f3ce269cfa7496223d1ff37d0
This commit is contained in:
parent
972d3fd8ae
commit
29a7702a99
@ -34,27 +34,9 @@ import datetime
|
||||
import functools
|
||||
import inspect
|
||||
import itertools
|
||||
import sys
|
||||
import json
|
||||
import uuid
|
||||
|
||||
is_simplejson = False
|
||||
if sys.version_info < (2, 7):
|
||||
# On Python <= 2.6, json module is not C boosted, so try to use
|
||||
# simplejson module if available
|
||||
try:
|
||||
import simplejson as json
|
||||
# NOTE(mriedem): Make sure we have a new enough version of simplejson
|
||||
# to support the namedobject_as_tuple argument. This can be removed
|
||||
# in the Kilo release when python 2.6 support is dropped.
|
||||
if 'namedtuple_as_object' in inspect.getargspec(json.dumps).args:
|
||||
is_simplejson = True
|
||||
else:
|
||||
import json
|
||||
except ImportError:
|
||||
import json
|
||||
else:
|
||||
import json
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import timeutils
|
||||
@ -193,8 +175,6 @@ def dumps(obj, default=to_primitive, **kwargs):
|
||||
Use dump_as_bytes() to ensure that the result type is ``bytes`` on Python 2
|
||||
and Python 3.
|
||||
"""
|
||||
if is_simplejson:
|
||||
kwargs['namedtuple_as_object'] = False
|
||||
return json.dumps(obj, default=default, **kwargs)
|
||||
|
||||
|
||||
@ -234,8 +214,6 @@ def dump(obj, fp, *args, **kwargs):
|
||||
The *default* parameter now uses :func:`to_primitive` by default.
|
||||
"""
|
||||
default = kwargs.get('default', to_primitive)
|
||||
if is_simplejson:
|
||||
kwargs['namedtuple_as_object'] = False
|
||||
return json.dump(obj, fp, default=default, *args, **kwargs)
|
||||
|
||||
|
||||
|
@ -21,7 +21,6 @@ import mock
|
||||
import netaddr
|
||||
from oslo_i18n import fixture
|
||||
from oslotest import base as test_base
|
||||
import simplejson
|
||||
import six
|
||||
import six.moves.xmlrpc_client as xmlrpclib
|
||||
|
||||
@ -36,7 +35,7 @@ class JSONUtilsTestMixin(object):
|
||||
super(JSONUtilsTestMixin, self).setUp()
|
||||
self.json_patcher = mock.patch.multiple(
|
||||
jsonutils, json=self.json_impl,
|
||||
is_simplejson=self.json_impl is simplejson)
|
||||
)
|
||||
self.json_impl_mock = self.json_patcher.start()
|
||||
|
||||
def tearDown(self):
|
||||
@ -108,10 +107,6 @@ class JSONUtilsTestJson(JSONUtilsTestMixin, test_base.BaseTestCase):
|
||||
json_impl = json
|
||||
|
||||
|
||||
class JSONUtilsTestSimpleJson(JSONUtilsTestMixin, test_base.BaseTestCase):
|
||||
json_impl = simplejson
|
||||
|
||||
|
||||
class ToPrimitiveTestCase(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(ToPrimitiveTestCase, self).setUp()
|
||||
|
@ -10,6 +10,5 @@ sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
|
||||
|
||||
oslotest>=1.10.0 # Apache-2.0
|
||||
simplejson>=2.2.0
|
||||
oslo.i18n>=1.5.0 # Apache-2.0
|
||||
coverage>=3.6
|
||||
|
Loading…
x
Reference in New Issue
Block a user