From 4eb30069bfb2e3144dce52a4ae3906a332dd01a2 Mon Sep 17 00:00:00 2001 From: Ricky Zhou Date: Wed, 3 Jun 2009 02:55:40 -0400 Subject: [PATCH] Try using simplejson instead if json-py is installed. Signed-off-by: James Vega (cherry picked from commit 416a6e8dd2ffed0320be02ee80e21f2e6910d573) --- plugins/Google/plugin.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index e1b6bee9e..98fd7dd1b 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -42,15 +42,21 @@ import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks +simplejson = None + +try: + simplejson = utils.python.universalImport('json') +except ImportError: + pass + try: - simplejson = utils.python.universalImport('json', 'simplejson', - 'local.simplejson') # The 3rd party simplejson module was included in Python 2.6 and renamed to # json. Unfortunately, this conflicts with the 3rd party json module. # Luckily, the 3rd party json module has a different interface so we test # to make sure we aren't using it. - if hasattr(simplejson, 'read'): - raise ImportError + if simplejson is None or hasattr(simplejson, 'read'): + simplejson = utils.python.universalImport('simplejson', + 'local.simplejson') except ImportError: raise callbacks.Error, \ 'You need Python2.6 or the simplejson module installed to use ' \