jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/508093 )
Change subject: Show deprecation warning for Python 2 ......................................................................
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(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
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
pywikibot-commits@lists.wikimedia.org