jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/971559 )
Change subject: [fix] check for valid family and site option after -help is processed
......................................................................
[fix] check for valid family and site option after -help is processed
pywikibot.handle_args() checks for a valid default site and prints an
error if either the family or the site code is invalid.
Make this test after -help option is processed to avoid unnecessary
api call when -help option is used. This is a workaround unless the
APISite.login(cookie_only=True) call no longer retrieves userinfo in
an early state i.e. instantiating the site.
Bug: T350272
Change-Id: I04a55c96a826c76b5bcf89893be92413985c6429
---
M pywikibot/bot.py
1 file changed, 27 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index d364f6a..2d73000 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -991,15 +991,6 @@
# argument not global -> specific bot script will take care
non_global_args.append(arg)
- if calledModuleName() != 'generate_user_files': # T261771
- try:
- pywikibot.Site()
- except (UnknownFamilyError, UnknownSiteError):
- pywikibot.exception(exc_info=False)
- sys.exit(1)
- if calledModuleName() == 'wrapper':
- pywikibot._sites.clear()
-
if username:
config.usernames[config.family][config.mylang] = username
@@ -1014,6 +1005,15 @@
show_help(show_global=do_help_val == 'global')
sys.exit(0)
+ if calledModuleName() != 'generate_user_files': # T261771
+ try:
+ pywikibot.Site()
+ except (UnknownFamilyError, UnknownSiteError):
+ pywikibot.exception(exc_info=False)
+ sys.exit(1)
+ if calledModuleName() == 'wrapper':
+ pywikibot._sites.clear()
+
debug('handle_args() completed.')
return non_global_args
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/971559
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I04a55c96a826c76b5bcf89893be92413985c6429
Gerrit-Change-Number: 971559
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Martineznovo <martineznovo(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged