From e20f09c2d047d782b4b471b2e8cf4a910b338db6 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 27 Feb 2009 05:14:11 +0000 Subject: [PATCH] Fixed #10006 -- Avoid inadvertently using third-party "json" module. In r9707 we added a preference to use Python's standard json module (Python 2.6 and beyond). However, there is also a third-party module called json that was being picked up by accident if it was installed. It isn't API compatible, so bad things happened. This change avoids that problem. Patch from markmuetz. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9910 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/simplejson/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django/utils/simplejson/__init__.py b/django/utils/simplejson/__init__.py index 2be6c3909c..9a8c5a348a 100644 --- a/django/utils/simplejson/__init__.py +++ b/django/utils/simplejson/__init__.py @@ -119,8 +119,14 @@ except ImportError: if not use_system_version: try: from json import * # Python 2.6 preferred over local copy. + + # There is a "json" package around that is not Python's "json", so we + # check for something that is only in the namespace of the version we + # want. + JSONDecoder + use_system_version = True - except ImportError: + except (ImportError, NameError): pass # If all else fails, we have a bundled version that can be used.