Last modified: 2014-10-20 12:36:28 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T74238, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 72238 - site.logged_in() returns False when logged in to sysop account
site.logged_in() returns False when logged in to sysop account
Status: NEW
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All Linux
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-19 16:24 UTC by CodeCat
Modified: 2014-10-20 12:36 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description CodeCat 2014-10-19 16:24:54 UTC
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.
Comment 1 Gerrit Notification Bot 2014-10-19 18:32:50 UTC
Change 167452 had a related patch set uploaded by XZise:
[FIX] TokenWallet: Assert a username

https://gerrit.wikimedia.org/r/167452
Comment 2 Gerrit Notification Bot 2014-10-19 18:42:14 UTC
Change 167452 merged by jenkins-bot:
[FIX] TokenWallet: Assert a username

https://gerrit.wikimedia.org/r/167452
Comment 3 CodeCat 2014-10-20 12:36:28 UTC
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())

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links