diff options
author | Takashi Kajinami <tkajinam@redhat.com> | 2021-07-17 01:07:54 +0900 |
---|---|---|
committer | Takashi Kajinami <tkajinam@redhat.com> | 2021-07-17 12:39:27 +0900 |
commit | 775ad9a56882b387e834eae7635f9f1ffa7c2f2c (patch) | |
tree | e1c691ffc636eb4522fb5243ba7bb3ea92ba2683 | |
parent | 653daf73ed03bc4b4dff386bc8246e0a96b6f2f9 (diff) | |
download | swift-775ad9a56882b387e834eae7635f9f1ffa7c2f2c.tar.gz |
Remove redundant usage of collections(.abc).Mapping
The json.loads method returns a normal python dict without any hook
defined, and type check using the Mapping class is redundant.
In Python 3.8
>>> import json
>>> type(json.loads('{"foo": {"var": "baz"}}'))
<class 'dict'>
In Python 2.7
>>> import json
>>> type(json.loads('{"foo": {"var": "baz"}}'))
<class 'dict'>
With this change we don't have to handle difference between Python 2
and Python 3 and later about import path we should use to import that
abstract class
Closes-Bug: #1936667
Change-Id: I9232311784d1feff2d669455dafde17ed9f751ad
-rw-r--r-- | swift/common/middleware/crypto/crypto_utils.py | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/swift/common/middleware/crypto/crypto_utils.py b/swift/common/middleware/crypto/crypto_utils.py index 60fe7c204..43f93ce4e 100644 --- a/swift/common/middleware/crypto/crypto_utils.py +++ b/swift/common/middleware/crypto/crypto_utils.py @@ -14,7 +14,6 @@ # limitations under the License. import base64 import binascii -import collections import json import os @@ -260,7 +259,7 @@ def load_crypto_meta(value, b64decode=True): if not isinstance(value, six.string_types): raise ValueError('crypto meta not a string') val = json.loads(urlparse.unquote_plus(value)) - if not isinstance(val, collections.Mapping): + if not isinstance(val, dict): raise ValueError('crypto meta not a Mapping') return b64_decode_meta(val) except (KeyError, ValueError, TypeError) as err: |