jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
Show deprecation warning for Python 2

Recommend using 3.5+ because 3.4 EOL has reached this march
https://devguide.python.org/#status-of-python-branches

Bug: T203471
Bug: T213287
Change-Id: I72e499f15f66c3c60a9644105a16c62978ccadeb
---
M HISTORY.rst
M pywikibot/__init__.py
M tests/utils.py
3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/HISTORY.rst b/HISTORY.rst
index ea9ebb1..e93bfac 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,7 @@
Current release
---------------

+* Deprecation warning: support for Python 2 will be dropped (T213287)
* botirc.IRCBot has been dropped
* Avoid using outdated browseragents (T222959)
* textlib: avoid infinite execution of regex (T222671)
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index a4cbfdc..f032eb1 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -65,7 +65,7 @@
MediaWikiVersion as _MediaWikiVersion,
redirect_func,
ModuleDeprecationWrapper as _ModuleDeprecationWrapper,
- PY2,
+ PY2, PYTHON_VERSION,
UnicodeMixin,
UnicodeType
)
@@ -122,6 +122,15 @@
# T111615: Python 2 requires __all__ is bytes
globals()['__all__'] = tuple(bytes(item) for item in __all__)

+ import sys
+ warn("""
+Python {version} will be dropped {when}.
+It is recommended to use Python 3.5 or above.
+See T213287 for further information.
+""".format(version=sys.version.split(None, 1)[0],
+ when='soon' if PYTHON_VERSION < (2, 7, 9) else 'in 2020'),
+ FutureWarning)
+
for _name in textlib_methods:
target = getattr(textlib, _name)
wrapped_func = redirect_func(target, since='20140820')
diff --git a/tests/utils.py b/tests/utils.py
index 3b69183..101b63b 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -643,6 +643,8 @@
@param command: executable to run and arguments to use
@type command: list of unicode
"""
+ if PY2:
+ command.insert(1, '-W ignore::FutureWarning:pywikibot:132')
if cryptography_version and cryptography_version < [1, 3, 4]:
command.insert(1, '-W ignore:Old version of cryptography:Warning')
# Any environment variables added on Windows must be of type

To view, visit change 508093. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I72e499f15f66c3c60a9644105a16c62978ccadeb
Gerrit-Change-Number: 508093
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)