jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326318?usp=email )
Change subject: api: Reuse current user during userinfo checks
......................................................................
api: Reuse current user during userinfo checks
Read the configured user once when checking API userinfo.
Reuse that snapshot for the mismatch decision and diagnostic message.
Change-Id: I17d34f5111a392b6986f182b3aec85a3a0a4f491
---
M pywikibot/data/api/_requests.py
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index 33b3e74..e0b263e 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -859,10 +859,11 @@
# that we are logged in as the correct user. If this is not the
# case, force a re-login.
username = result['query']['userinfo']['name']
- if (self.site.user() is not None and self.site.user() != username
+ current_user = self.site.user()
+ if (current_user is not None and current_user != username
and self.site._loginstatus != LoginStatus.IN_PROGRESS):
self._relogin(f'Logged in as {username!r} instead of '
- f'{self.site.user()!r}.')
+ f'{current_user!r}.')
return True
return False
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326318?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I17d34f5111a392b6986f182b3aec85a3a0a4f491
Gerrit-Change-Number: 1326318
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]