diff options
author | PMickael <mickael.penhard@gmail.com> | 2015-12-02 09:59:38 +0100 |
---|---|---|
committer | PMickael <mickael.penhard@gmail.com> | 2015-12-02 09:59:38 +0100 |
commit | 27f0d8c82d577af56f0d384b38541e86ba95ea77 (patch) | |
tree | 185ccefab65d649080a8364d2ce6f6563e687688 /kombu/utils/json.py | |
parent | 91d0325f770bde755cc96a70dd1cecb66ba97aba (diff) | |
download | kombu-27f0d8c82d577af56f0d384b38541e86ba95ea77.tar.gz |
Catch exception with simplejson "Unpaired high surrogate"
Diffstat (limited to 'kombu/utils/json.py')
-rw-r--r-- | kombu/utils/json.py | 11 |
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) |