jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1132169?usp=email )

Change subject: [bugfix] no longer follow redirects when the browser is opened
......................................................................

[bugfix] no longer follow redirects when the browser is opened

Also use bot.open_webbrowser with blockpageschecker.py script.

Bug: T390447
Change-Id: Ic8999cd8cf152bb2fbe86d6e3adf1e7f5f579647
---
M pywikibot/bot.py
M scripts/blockpageschecker.py
2 files changed, 14 insertions(+), 6 deletions(-)

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




diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index d52b250..8a369a6 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -982,8 +982,12 @@


 def open_webbrowser(page: pywikibot.page.BasePage) -> None:
-    """Open the web browser displaying the page and wait for input."""
-    webbrowser.open(page.full_url())
+    """Open the web browser displaying the page and wait for input.
+
+    .. versionchanged:: 10.1
+       No longer follow a redirect.
+    """
+    webbrowser.open(f'{page.full_url()}?redirect=no')
     i18n.input('pywikibot-enter-finished-browser')


diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py
index adf2cc0..68d0f36 100755
--- a/scripts/blockpageschecker.py
+++ b/scripts/blockpageschecker.py
@@ -45,20 +45,24 @@

 """
 #
-# (C) Pywikibot team, 2007-2024
+# (C) Pywikibot team, 2007-2025
 #
 # Distributed under the terms of the MIT license.
 #
 from __future__ import annotations

 import re
-import webbrowser
 from itertools import chain
 from typing import NamedTuple

 import pywikibot
 from pywikibot import i18n, pagegenerators
-from pywikibot.bot import ConfigParserBot, ExistingPageBot, SingleSiteBot
+from pywikibot.bot import (
+    ConfigParserBot,
+    ExistingPageBot,
+    SingleSiteBot,
+    open_webbrowser,
+)
 from pywikibot.editor import TextEditor
 from pywikibot.exceptions import Error

@@ -198,7 +202,7 @@
             'Do you want to open the page?',
             [('with browser', 'b'), ('with gui', 'g'), ('no', 'n')], 'n')
         if choice == 'b':
-            webbrowser.open(f'{page.full_url()}?redirect=no')
+            open_webbrowser(page)
         elif choice == 'g':
             editor = TextEditor()
             editor.edit(page.text)

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1132169?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: Ic8999cd8cf152bb2fbe86d6e3adf1e7f5f579647
Gerrit-Change-Number: 1132169
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[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]

Reply via email to