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

Change subject: [IMPR] Show a warning if Pywikibot is running with Python 3.7
......................................................................

[IMPR] Show a warning if Pywikibot is running with Python 3.7

Also use timeout with TestPwb.test_argv

Bug: T379227
Change-Id: Idf55843b5540bec81fca2a4fe462602b5e56a664
---
M ROADMAP.rst
M docs/index.rst
M pywikibot/__init__.py
M tests/pwb_tests.py
M tests/utils.py
5 files changed, 19 insertions(+), 3 deletions(-)

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




diff --git a/ROADMAP.rst b/ROADMAP.rst
index 7bb2dcb..7ef2387 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,6 +1,7 @@
 Current Release Changes
 =======================

+* Python 3.7 support will be discontinued and probably this is the last 
version supporting it
 * Retry :meth:`data.sparql.SparqlQuery.query` on internal server error (500) 
(:phab:`T378788`)
 * Extract 
:meth:`APISite.linktrail()<pywikibot.site._apisite.APISite.linktrail>`
   for hr-wiki (:phab:`T378787`)
@@ -66,6 +67,7 @@
 Pending removal in Pywikibot 10
 -------------------------------

+* 9.6.0: Python 3.7 support is deprecated and will be dropped with Pywikibot 10
 * 9.1.0: :func:`version.svn_rev_info` and :func:`version.getversion_svn` will 
be removed. SVN is no longer supported.
   (:phab:`T362484`)
 * 7.7.0: :mod:`tools.threading` classes should no longer imported from 
:mod:`tools`
diff --git a/docs/index.rst b/docs/index.rst
index 7929f58..ea1163c 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -21,7 +21,8 @@
 whether you have Python installed and to find its version, just type
 ``python`` at the CMD or shell prompt.

-Python 3.7 or higher is currently required to run the bot.
+Python 3.7 or higher is currently required to run the bot but Python 3.8 or
+higher is recommended. Python 3.7 support will be dropped with Pywikibot 10 
soon.

 Pywikibot and this documentation are licensed under the
 :ref:`MIT license`;
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 2375309..6819a7f 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -59,7 +59,7 @@
 )
 from pywikibot.site import BaseSite as _BaseSite
 from pywikibot.time import Timestamp
-from pywikibot.tools import normalize_username
+from pywikibot.tools import PYTHON_VERSION, normalize_username


 if TYPE_CHECKING:
@@ -87,6 +87,15 @@

 _sites: dict[str, APISite] = {}

+if PYTHON_VERSION < (3, 8):
+    __version = sys.version.split(maxsplit=1)[0]
+    warn(f"""
+
+    Python {__version} will be dropped soon with Pywikibot 10.
+    It is recommended to use Python 3.8 or above.
+    See phab: T379227 for further information.
+""", FutureWarning)  # adjust this line no in utils.execute()
+

 @cache
 def _code_fam_from_url(url: str, name: str | None = None
diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
index 5bfbd95..abf0293 100755
--- a/tests/pwb_tests.py
+++ b/tests/pwb_tests.py
@@ -83,7 +83,7 @@
         script_opts = ['-help']
         command = [script_path, *script_opts]
         without_global_args = execute_pwb(command)
-        with_no_global_args = execute_pwb(['-maxlag:5', *command])
+        with_no_global_args = execute_pwb(['-maxlag:5', *command], timeout=10)
         self.assertEqual(without_global_args['stdout'],
                          with_no_global_args['stdout'])
         self.assertEqual(without_global_args['stdout'].rstrip(),
diff --git a/tests/utils.py b/tests/utils.py
index c80e331..89b92bb 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -23,6 +23,7 @@
 from pywikibot.exceptions import APIError
 from pywikibot.login import LoginStatus
 from pywikibot.site import Namespace
+from pywikibot.tools import PYTHON_VERSION
 from pywikibot.tools.collections import EMPTY_DEFAULT
 from tests import _pwb_py

@@ -473,6 +474,9 @@

     :param command: executable to run and arguments to use
     """
+    if PYTHON_VERSION < (3, 8):
+        command.insert(1, '-W ignore::FutureWarning:pywikibot:97')
+
     env = os.environ.copy()

     # Prevent output by test package; e.g. 'max_retries reduced from x to y'

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1088565?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: Idf55843b5540bec81fca2a4fe462602b5e56a664
Gerrit-Change-Number: 1088565
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: JJMC89 <jjmc89.wikime...@gmail.com>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org
To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org

Reply via email to