jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/735929 )
Change subject: FEAT] skip InvalidPageError in cosmetic_changes.py ......................................................................
FEAT] skip InvalidPageError in cosmetic_changes.py
Bug: T293612 Change-Id: I860ae159c9ab4a5dc8f853f22a44dbd9f45b9626 --- M scripts/cosmetic_changes.py 1 file changed, 15 insertions(+), 4 deletions(-)
Approvals: Meno25: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py index d4e931d..d7d4c04 100755 --- a/scripts/cosmetic_changes.py +++ b/scripts/cosmetic_changes.py @@ -44,6 +44,7 @@ NoRedirectPageBot, ) from pywikibot.cosmetic_changes import CANCEL, CosmeticChangesToolkit +from pywikibot.exceptions import InvalidPageError
warning = """ @@ -72,12 +73,22 @@ }
def treat_page(self) -> None: - """Treat page with the cosmetic toolkit.""" + """Treat page with the cosmetic toolkit. + + .. versionchanged:: 7.0 + skip if InvalidPageError is raised + """ cc_toolkit = CosmeticChangesToolkit(self.current_page, ignore=self.opt.ignore) - changed_text = cc_toolkit.change(self.current_page.text) - if changed_text is not False: - self.put_current(new_text=changed_text, + try: + old_text = self.current_page.text + except InvalidPageError: + pywikibot.exception() + return + + new_text = cc_toolkit.change(old_text) + if new_text is not False: + self.put_current(new_text=new_text, summary=self.opt.summary, asynchronous=self.opt['async'])
pywikibot-commits@lists.wikimedia.org