summaryrefslogtreecommitdiff
path: root/sphinx/util/jsonimpl.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-08-05 12:02:27 +0200
committerGeorg Brandl <georg@python.org>2010-08-05 12:02:27 +0200
commit29547f798172a34e00fded1da2f9dc0b0f31bc09 (patch)
tree2658deff7f9b8b9a8fdb7da0d99c2a0190df2f09 /sphinx/util/jsonimpl.py
parent01c501054e4e42e2c614c7a244f8b769938909f8 (diff)
downloadsphinx-git-29547f798172a34e00fded1da2f9dc0b0f31bc09.tar.gz
#488: Fix crash when json-py is installed, which provides a ``json`` module but is incompatible to simplejson.
Diffstat (limited to 'sphinx/util/jsonimpl.py')
-rw-r--r--sphinx/util/jsonimpl.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/sphinx/util/jsonimpl.py b/sphinx/util/jsonimpl.py
index b83661a7e..fda85b5e3 100644
--- a/sphinx/util/jsonimpl.py
+++ b/sphinx/util/jsonimpl.py
@@ -13,8 +13,10 @@ import UserString
try:
import json
+ # json-py's json module has not JSONEncoder; this will raise AttributeError
+ # if json-py is imported instead of the built-in json module
JSONEncoder = json.JSONEncoder
-except ImportError:
+except (ImportError, AttributeError):
try:
import simplejson as json
JSONEncoder = json.JSONEncoder