jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/618384 )

Change subject: [IMPR] Deprecate BaseBot.stop() method
......................................................................

[IMPR] Deprecate BaseBot.stop() method

Deprecate BaseBot.stop() method in favour of BaseBot.generator.close() call

Change-Id: I776a9ffe70c1135ec71912442d21d470d3e3f6c3
---
M pywikibot/bot.py
M scripts/redirect.py
2 files changed, 4 insertions(+), 4 deletions(-)

Approvals:
  D3r1ck01: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 70b2b14..8836e64 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1270,9 +1270,11 @@
             return True
         return False

+    @deprecated('generator.close()', since='20200804')
     def stop(self):
         """Stop iterating."""
-        raise GeneratorExit
+        pywikibot.output('Generator has been stopped.')
+        self.generator.close()

     def quit(self):
         """Cleanup and quit processing."""
@@ -1418,8 +1420,6 @@
                 self._treat_counter += 1
             else:
                 self._generator_completed = True
-        except GeneratorExit:
-            pywikibot.output('Generator has been stopped.')
         except QuitKeyboardInterrupt:
             pywikibot.output('\nUser quit %s bot run...' %
                              self.__class__.__name__)
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 6248d33..3261cc4 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -668,7 +668,7 @@
         if self._treat_counter >= self.getOption('limit'):
             pywikibot.output('\nNumber of pages reached the limit. '
                              'Script terminated.')
-            self.stop()
+            self.generator.close()
         super().treat(page)



--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/618384
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: I776a9ffe70c1135ec71912442d21d470d3e3f6c3
Gerrit-Change-Number: 618384
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to