From 29547f798172a34e00fded1da2f9dc0b0f31bc09 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 5 Aug 2010 12:02:27 +0200 Subject: [PATCH] #488: Fix crash when json-py is installed, which provides a ``json`` module but is incompatible to simplejson. --- CHANGES | 3 +++ sphinx/util/jsonimpl.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index cb80d72c6..60c55e7a9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 1.0.2 (in development) ============================== +* #488: Fix crash when json-py is installed, which provides a + ``json`` module but is incompatible to simplejson. + * #480: Fix handling of target naming in intersphinx. * #486: Fix removal of ``!`` for all cross-reference roles. 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