summaryrefslogtreecommitdiff
path: root/kombu/utils/json.py
diff options
context:
space:
mode:
authorPMickael <mickael.penhard@gmail.com>2015-12-02 09:59:38 +0100
committerPMickael <mickael.penhard@gmail.com>2015-12-02 09:59:38 +0100
commit27f0d8c82d577af56f0d384b38541e86ba95ea77 (patch)
tree185ccefab65d649080a8364d2ce6f6563e687688 /kombu/utils/json.py
parent91d0325f770bde755cc96a70dd1cecb66ba97aba (diff)
downloadkombu-27f0d8c82d577af56f0d384b38541e86ba95ea77.tar.gz
Catch exception with simplejson "Unpaired high surrogate"
Diffstat (limited to 'kombu/utils/json.py')
-rw-r--r--kombu/utils/json.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/kombu/utils/json.py b/kombu/utils/json.py
index a5227467..693a72ee 100644
--- a/kombu/utils/json.py
+++ b/kombu/utils/json.py
@@ -43,4 +43,13 @@ def loads(s, _loads=json.loads, decode_bytes=IS_PY3):
s = s.decode('utf-8')
elif isinstance(s, buffer_t):
s = text_t(s) # ... awwwwwww :(
- return _loads(s)
+
+ if json.__name__ == 'simplejson':
+ try:
+ return _loads(s)
+ # catch simplejson.decoder.JSONDecodeError: Unpaired high surrogate
+ except json.decoder.JSONDecodeError, e:
+ import json as fulljson
+ return fulljson.loads(s)
+ else:
+ return _loads(s)