jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/435666 )
Change subject: [bugfix] Terminate QuitKeyboardInterrupt sucessfully ......................................................................
[bugfix] Terminate QuitKeyboardInterrupt sucessfully
Terminate a BaseBot script sucessfully even when an input answer is [q]uit which raises QuitKeyboardInterrupt. On Python 2 Plattforms this terminates as an exception.
Bug: T195687 Change-Id: I284e2452521fe5915d7e9d6451ee2729869cf16e --- M pywikibot/bot.py 1 file changed, 7 insertions(+), 3 deletions(-)
Approvals: Dvorapa: Looks good to me, but someone else must approve Framawiki: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py index e6a058b..c246d99 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -1394,10 +1394,14 @@
# exc_info contains exception from self.run() while terminating exc_info = sys.exc_info() - if exc_info[0] is None or exc_info[0] is KeyboardInterrupt: - pywikibot.output("Script terminated successfully.") + pywikibot.output('Script terminated ', newline=False) + # Python 2 also needs QuitKeyboardInterrupt + # to be compared with exc_info[0] (T195687) + if exc_info[0] is None or exc_info[0] in (KeyboardInterrupt, + QuitKeyboardInterrupt): + pywikibot.output('successfully.') else: - pywikibot.output("Script terminated by exception:\n") + pywikibot.output('by exception:\n') pywikibot.exception()
def treat(self, page):
pywikibot-commits@lists.wikimedia.org