From 3773f8905b548b1ee0bc84fcb5afa75d93f63152 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Fri, 14 Sep 2018 16:35:24 -0500 Subject: [PATCH] Drop simplejson usage simplejson was mainly needed before the json standard library supported everything we need. This was when we supported Python versions earlier than 2.7. The standard library for all Python versions we now support is good enough and we should clean up unnecessary third party libs. Change-Id: I866445ffba9633db1de5ba615dcc19450f5d02e7 Signed-off-by: Sean McGinnis --- .../unit/volume/drivers/netapp/eseries/test_client.py | 8 +++----- cinder/volume/drivers/dell_emc/sc/storagecenter_api.py | 9 ++++----- cinder/volume/drivers/netapp/eseries/client.py | 3 +-- lower-constraints.txt | 1 - requirements.txt | 1 - 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/netapp/eseries/test_client.py b/cinder/tests/unit/volume/drivers/netapp/eseries/test_client.py index 16f0e27c48f..30c007c4efc 100644 --- a/cinder/tests/unit/volume/drivers/netapp/eseries/test_client.py +++ b/cinder/tests/unit/volume/drivers/netapp/eseries/test_client.py @@ -16,20 +16,18 @@ # under the License. import copy +import json import ddt -import json import mock -from simplejson import scanner from six.moves import http_client from cinder import exception from cinder import test from cinder.tests.unit.volume.drivers.netapp.eseries import fakes as \ eseries_fake -from cinder.volume.drivers.netapp.eseries import exception as es_exception - from cinder.volume.drivers.netapp.eseries import client +from cinder.volume.drivers.netapp.eseries import exception as es_exception from cinder.volume.drivers.netapp import utils as na_utils @@ -1146,7 +1144,7 @@ class NetAppEseriesClientDriverTestCase(test.TestCase): def test_invoke_bad_content_type(self): """Tests the invoke behavior with a non-JSON response""" fake_response = mock.Mock() - fake_response.json = mock.Mock(side_effect=scanner.JSONDecodeError( + fake_response.json = mock.Mock(side_effect=ValueError( '', '{}', 1)) fake_response.status_code = http_client.FAILED_DEPENDENCY fake_response.text = "Fake Response" diff --git a/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py b/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py index a453b296099..43f1ecedfd7 100644 --- a/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py +++ b/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py @@ -20,7 +20,6 @@ import eventlet from oslo_log import log as logging from oslo_utils import excutils import requests -from simplejson import scanner import six from six.moves import http_client import uuid @@ -599,8 +598,8 @@ class SCApi(object): LOG.error('Error invalid json: %s', blob) except TypeError as ex: LOG.error('Error TypeError. %s', ex) - except scanner.JSONDecodeError as ex: - LOG.error('Error JSONDecodeError. %s', ex) + except ValueError as ex: + LOG.error('JSON decoding error. %s', ex) # We are here so this went poorly. Log our blob. LOG.debug('_get_json blob %s', blob) return None @@ -618,8 +617,8 @@ class SCApi(object): LOG.error('Invalid API object: %s', blob) except TypeError as ex: LOG.error('Error TypeError. %s', ex) - except scanner.JSONDecodeError as ex: - LOG.error('Error JSONDecodeError. %s', ex) + except ValueError as ex: + LOG.error('JSON decoding error. %s', ex) LOG.debug('_get_id failed: blob %s', blob) return None diff --git a/cinder/volume/drivers/netapp/eseries/client.py b/cinder/volume/drivers/netapp/eseries/client.py index 974787eac39..774969b5e4f 100644 --- a/cinder/volume/drivers/netapp/eseries/client.py +++ b/cinder/volume/drivers/netapp/eseries/client.py @@ -28,7 +28,6 @@ import uuid from oslo_log import log as logging import requests -from simplejson import scanner import six from six.moves import urllib @@ -287,7 +286,7 @@ class RestClient(WebserviceClient): res_dict = res.json() if res.text else None # This should only occur if we expected JSON, but were sent # something else - except scanner.JSONDecodeError: + except ValueError: res_dict = None if cinder_utils.TRACE_API: diff --git a/lower-constraints.txt b/lower-constraints.txt index 3f912342b99..b8c8584b877 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -131,7 +131,6 @@ rfc3986==1.1.0 Routes==2.3.1 rsa==3.4.2 rtslib-fb==2.1.65 -simplejson==3.5.1 six==1.10.0 smmap2==2.0.3 snowballstemmer==1.2.1 diff --git a/requirements.txt b/requirements.txt index 3fb1d598319..a9bfd80156d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -51,7 +51,6 @@ retrying!=1.3.0,>=1.2.3 # Apache-2.0 Routes>=2.3.1 # MIT taskflow>=2.16.0 # Apache-2.0 rtslib-fb>=2.1.65 # Apache-2.0 -simplejson>=3.5.1 # MIT six>=1.10.0 # MIT SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT sqlalchemy-migrate>=0.11.0 # Apache-2.0