jenkins-bot has submitted this change and it was merged.
Change subject: Use main account for checking user existence ......................................................................
Use main account for checking user existence
When running a bot using a Special:BotPassword username but no provided password, use the main account username to check that the user exists before prompting for the password.
For BotPasswords see https://www.mediawiki.org/wiki/Manual:Bot_passwords
Bug: T142623 Change-Id: I2bf629b3f6b21f375cacdabc2518c7ac0cf3cd49 --- M pywikibot/login.py 1 file changed, 7 insertions(+), 4 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved Dalba: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py index df1152c..20f38f7 100644 --- a/pywikibot/login.py +++ b/pywikibot/login.py @@ -122,21 +122,24 @@
@raises NoUsername: Username doesnt exist in user list. """ + # convert any Special:BotPassword usernames to main account equivalent + main_username = self.username.partition('@')[0] + try: - data = self.site.allusers(start=self.username, total=1) + data = self.site.allusers(start=main_username, total=1) user = next(iter(data)) except pywikibot.data.api.APIError as e: if e.code == 'readapidenied': pywikibot.warning('Could not check user %s exists on %s' - % (self.username, self.site)) + % (main_username, self.site)) return else: raise
- if user['name'] != self.username: + if user['name'] != main_username: # Report the same error as server error code NotExists raise NoUsername('Username '%s' does not exist on %s' - % (self.username, self.site)) + % (main_username, self.site))
def botAllowed(self): """