[Pywikipedia-l] All bots are broken

Milos Rancic millosh at gmail.com
Tue Sep 22 07:02:52 UTC 2009


On Mon, Sep 21, 2009 at 09:55, Nicolas Dumazet <nicdumz at gmail.com> wrote:
> 2009/9/21 Milos Rancic <millosh at gmail.com>:
>> I've found one more thing...
>>
>> Inside of query.py there are lines for loading json or simplejson:
>>
>> try:
>>    #For Python 2.6 newer
>>    import json
>> except ImportError:
>>    import simplejson as json
>>
>> I am not using 2.6, but 2.5.4, but I have module json.
>
> What module is this? A json module, under 2.5? Where did you get it?
>
>>
>> However, there are two json.loads commands:
>>
>>            # This will also work, but all unicode strings will need
>> to be converted from \u notation
>>            # decodedObj = eval( jsontext )
>>            if back_response:
>>                return res, json.loads( jsontext )
>>            else:
>>                return json.loads( jsontext )
>>
>> ... and simplejson has it, but json doesn't. So, I've fixed my
>> pywikipediabot by commenting try-except at the beginning and leaving
>> just "import simplejson as json".
>
> import json is meant for 2.6. In 2.6, json _has_ the loads method:
> http://docs.python.org/library/json.html#json.loads
>
>
> --
> Nicolas Dumazet — NicDumZ
>
> _______________________________________________
> Pywikipedia-l mailing list
> Pywikipedia-l at lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
>

Here is the info:

millosh at wintermute:~$ dpkg -l | grep json
ii  python-cjson                         1.0.5-1
Very fast JSON encoder/decoder for Python
ii  python-cjson-dbg                     1.0.5-1
Very fast JSON encoder/decoder for Python (debug extension)
ii  python-json                          3.4-4                       a
JSON (http://json.org) reader and writer in Python
ii  python-simplejson                    2.0.9-1
Simple, fast, extensible JSON encoder/decoder for Python

millosh at wintermute:~$ python
Python 2.5.4 (r254:67916, Feb 17 2009, 20:16:45)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> dir(json)
['JsonReader', 'JsonWriter', 'ReadException', 'WriteException',
'_StringGenerator', '__builtins__', '__doc__', '__file__', '__name__',
'read', 'string', 'types', 'write']

Debian Unstable is installed on computer.



More information about the Pywikipedia-l mailing list