Revision: 7144
Author:   alexsh
Date:     2009-08-12 21:29:35 +0000 (Wed, 12 Aug 2009)

Log Message:
-----------
change simplejson to internal json for 2.6 (take exception to simplejson)

Modified Paths:
--------------
    trunk/pywikipedia/query.py

Modified: trunk/pywikipedia/query.py
===================================================================
--- trunk/pywikipedia/query.py  2009-08-11 16:35:49 UTC (rev 7143)
+++ trunk/pywikipedia/query.py  2009-08-12 21:29:35 UTC (rev 7144)
@@ -25,7 +25,13 @@
 __version__ = '$Id$'
 #
 
-import wikipedia, simplejson, urllib, time
+import wikipedia, urllib, time
+try:
+    #For Python 2.6 newer
+    import json
+except ImportError:
+    import simplejson as json
+    
 
 def GetData(params, site = None, verbose = False, useAPI = True, retryCount = 
5, encodeTitle = True, sysop = False, back_response = False):
     """Get data from the query api, and convert it into a data object
@@ -91,15 +97,15 @@
             # This will also work, but all unicode strings will need to be 
converted from \u notation
             # decodedObj = eval( jsontext )
             if back_response:
-                return res, simplejson.loads( jsontext )
+                return res, json.loads( jsontext )
             else:
-                return simplejson.loads( jsontext )
+                return json.loads( jsontext )
 
         except ValueError, error:
             retryCount -= 1
             wikipedia.output(u"Error downloading data: %s" % error)
             wikipedia.output(u"Request %s:%s" % (site.lang, path))
-            wikipedia.debugDump('ApiGetDataParse', site, str(error) + '\n%s' % 
path, jsontext)
+            wikipedia.debugDump('ApiGetDataParse', site, str(error) + 
'\n%s\n%s' % (site.hostname(), path), jsontext)
             lastError = error
             if retryCount >= 0:
                 wikipedia.output(u"Retrying in %i seconds..." % 
retry_idle_time)



_______________________________________________
Pywikipedia-svn mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn

Reply via email to