Last modified: 2014-09-12 21:41:34 UTC
In the user-config a specific site is set but via 'pywikibot.getSite' or 'pywikibot.Site' another (unrelated) Site (family) is chosen. But in fact after a few requests to the unrelated site it's also querying the user configured site. I found this when I was trying to figure out why I got warnings for a complete legit API call. >>> import pywikibot >>> wp = pywikibot.getSite("en", "wikipedia") >>> wp.tokens['edit'] https://en.wikipedia.org/w/api.php https://en.wikipedia.org/w/api.php https://en.wikipedia.org/w/api.php https://en.wikipedia.org/w/api.php https://en.wikipedia.org/w/api.php http://wiki.kerbalspaceprogram.com/w/api.php WARNING: API warning (query): Unrecognized value for parameter 'meta': tokens WARNING: API warning (main): Unrecognized parameter: 'type' Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pywikibot/site.py", line 1200, in __getitem__ return storage[key] KeyError: 'csrf' If I change the user configuration to the English Wikipedia all api.php calls vanish except one to en.wikipedia.org and I get a legit result. Each URI is directly printed in the first line threadedhttp's Http.request method.
Okay a bit more output: wikipedia:en /w/api.php maxlag=5&format=json&meta=siteinfo%7Cuserinfo&action=query&siprop=namespaces%7Cnamespacealiases%7Cgeneral&uiprop=blockinfo%7Chasmsg wikipedia:en /w/api.php action=query&format=json&meta=userinfo&maxlag=5&uiprop=blockinfo%7Cgroups%7Chasmsg%7Crights wikipedia:en /w/api.php action=query&format=json&meta=userinfo&maxlag=5&uiprop=blockinfo%7Cgroups%7Chasmsg%7Crights wikipedia:en /w/api.php action=query&format=json&meta=userinfo&maxlag=5&uiprop=blockinfo%7Cgroups%7Chasmsg%7Crights wikipedia:en /w/api.php maxlag=5&format=json&meta=siteinfo%7Cuserinfo&action=query&siprop=general&uiprop=blockinfo%7Chasmsg ksp:en /w/api.php maxlag=5&format=json&meta=tokens%7Cuserinfo&action=query&type=csrf&uiprop=blockinfo%7Chasmsg This is now directly above the assert in request of the http module. It prints the URI (always relative) the site (enwp except for the last) and the paramstring.
Tried to reproduce, no success so far.
Change 159991 had a related patch set uploaded by XZise: [FIX] Tokens: Return the csrf token and request correct site https://gerrit.wikimedia.org/r/159991
Change 159991 merged by jenkins-bot: [FIX] Tokens: Return the csrf token and request correct site https://gerrit.wikimedia.org/r/159991