summaryrefslogtreecommitdiff
path: root/kombu/utils/json.py
diff options
context:
space:
mode:
authorAsk Solem <ask@celeryproject.org>2016-04-01 15:04:01 -0700
committerAsk Solem <ask@celeryproject.org>2016-04-01 15:04:01 -0700
commite851974bc6e0dadc549b976ef6217dd037cf168d (patch)
tree7e3da4e9fe4617d21981fe0e2ecc7c6cb6f5bf2a /kombu/utils/json.py
parent7674b8b4298834b6dbde8ef1789583d8ece0bbed (diff)
downloadkombu-e851974bc6e0dadc549b976ef6217dd037cf168d.tar.gz
94% coverage
Diffstat (limited to 'kombu/utils/json.py')
-rw-r--r--kombu/utils/json.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/kombu/utils/json.py b/kombu/utils/json.py
index be4e6a05..3b3d1911 100644
--- a/kombu/utils/json.py
+++ b/kombu/utils/json.py
@@ -11,6 +11,11 @@ try:
except ImportError: # pragma: no cover
import json # noqa
+ class _DecodeError(Exception): # noqa
+ pass
+else:
+ from simplejson.decoder import JSONDecodeError as _DecodeError
+
IS_PY3 = sys.version_info[0] == 3
_encoder_cls = type(json._default_encoder)
@@ -47,11 +52,8 @@ def loads(s, _loads=json.loads, decode_bytes=IS_PY3):
elif isinstance(s, buffer_t):
s = text_t(s) # ... awwwwwww :(
- if json.__name__ == 'simplejson':
- try:
- return _loads(s)
- # catch simplejson.decoder.JSONDecodeError: Unpaired high surrogate
- except json.decoder.JSONDecodeError:
- return stdjson.loads(s)
- else:
+ try:
return _loads(s)
+ except _DecodeError:
+ # catch "Unpaired high surrogate" error
+ return stdjson.loads(s)