https://bugzilla.wikimedia.org/show_bug.cgi?id=72238
Bug ID: 72238 Summary: site.logged_in() returns False when logged in to sysop account Product: Pywikibot Version: core (2.0) Hardware: All OS: Linux Status: NEW Severity: normal Priority: Unprioritized Component: General Assignee: Pywikipedia-bugs@lists.wikimedia.org Reporter: codecat42@gmail.com Web browser: --- Mobile Platform: ---
My user-config.py contains:
usernames['wiktionary']['en'] = u'MewBot' sysopnames['wiktionary']['en'] = u'CodeCat'
So when I perform an action that requires sysop access, it should switch to another account, and indeed it does. It asks me to log in to the sysop account.
But once logged in, and then attempting to delete a page, the following occurs:
Traceback (most recent call last): File "Desktop/bot/deleteempty.py", line 13, in <module> current.delete(reason="Empty category; recreate when needed", prompt=False) File "(redacted)/pywikibot/pywikibot/tools.py", line 529, in wrapper return obj(*__args, **__kw) File "(redacted)/pywikibot/pywikibot/page.py", line 1489, in delete return self.site.deletepage(self, reason) File "(redacted)/pywikibot/pywikibot/site.py", line 932, in callee return fn(self, *args, **kwargs) File "(redacted)/pywikibot/pywikibot/site.py", line 4033, in deletepage token = self.tokens['delete'] File "(redacted)/pywikibot/pywikibot/site.py", line 1279, in __getitem__ assert(self.site.logged_in()) AssertionError <type 'exceptions.AssertionError'>
I inserted some test code into site.py to see why the assertion is failing. And curiously, self.site.logged_in() returns False, but self.site.logged_in(sysop=True) returns True. Tracking it down further to the logged_in method, it appears that the condition
if self.userinfo['name'] != self._username[sysop]: return False
is what is returning False. Inserting a test to display the two values being compared, it turns out that self.userinfo['name'] is the sysop user name, but self._username[sysop] is the regular user name. This is not terribly surprising as sysop is False in this case.
https://bugzilla.wikimedia.org/show_bug.cgi?id=72238
--- Comment #1 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 167452 had a related patch set uploaded by XZise: [FIX] TokenWallet: Assert a username
https://gerrit.wikimedia.org/r/167452
https://bugzilla.wikimedia.org/show_bug.cgi?id=72238
Gerrit Notification Bot gerritadmin@wikimedia.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |PATCH_TO_REVIEW
https://bugzilla.wikimedia.org/show_bug.cgi?id=72238
--- Comment #2 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 167452 merged by jenkins-bot: [FIX] TokenWallet: Assert a username
https://gerrit.wikimedia.org/r/167452
https://bugzilla.wikimedia.org/show_bug.cgi?id=72238
CodeCat codecat42@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|PATCH_TO_REVIEW |NEW
--- Comment #3 from CodeCat codecat42@gmail.com --- The problem is still occurring, but now in a different piece of code.
File "Desktop/bot/deleteempty.py", line 13, in <module> current.delete(reason="Empty category; recreate when needed", prompt=False) File "(redacted)/pywikibot/pywikibot/tools.py", line 529, in wrapper return obj(*__args, **__kw) File "(redacted)/pywikibot/pywikibot/page.py", line 1489, in delete return self.site.deletepage(self, reason) File "(redacted)/pywikibot/pywikibot/site.py", line 932, in callee return fn(self, *args, **kwargs) File "(redacted)/pywikibot/pywikibot/site.py", line 4033, in deletepage token = self.tokens['delete'] File "(redacted)/pywikibot/pywikibot/site.py", line 1294, in __getitem__ self.load_tokens([key], all=False if user_tokens else None) File "(redacted)/pywikibot/pywikibot/site.py", line 1264, in load_tokens assert(self.site.logged_in())
pywikipedia-bugs@lists.wikimedia.org