jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/491045 )
Change subject: [cleanup] remove old pre Python 2.5 stuff ......................................................................
[cleanup] remove old pre Python 2.5 stuff
- ctypes was introduces with Python 2.5. We only support 2.7 or higher and old parts can be removed. - Rename Win32CtypesUI to Win32UI - Derive Win32UI from terminal_interface_base.UI directly - Deprecate Win32CtypesUI and 'Win32BaseUI'. 'Win32UI' should be used instead - Change test accordingly
Change-Id: Ie1b9423770c4a80cef05ebcd3351a5638022561c --- M pywikibot/userinterfaces/terminal_interface_win32.py M tests/ui_tests.py 2 files changed, 19 insertions(+), 17 deletions(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_win32.py b/pywikibot/userinterfaces/terminal_interface_win32.py index 6b94693..78f18c9 100755 --- a/pywikibot/userinterfaces/terminal_interface_win32.py +++ b/pywikibot/userinterfaces/terminal_interface_win32.py @@ -1,22 +1,20 @@ # -*- coding: utf-8 -*- """User interface for Win32 terminals.""" # -# (C) Pywikibot team, 2003-2018 +# (C) Pywikibot team, 2003-2019 # # Distributed under the terms of the MIT license. # from __future__ import absolute_import, division, unicode_literals
+from pywikibot.tools import ModuleDeprecationWrapper + from pywikibot.userinterfaces import ( terminal_interface_base, win32_unicode, )
-try: - import ctypes - ctypes_found = True -except ImportError: - ctypes_found = False +import ctypes
windowsColors = { 'default': 7, @@ -39,24 +37,23 @@ }
-# Compat for python <= 2.5 class Win32BaseUI(terminal_interface_base.UI):
- """User interface for Win32 terminals without ctypes.""" + """DEPRECATED. User interface for Win32 terminals without ctypes."""
def __init__(self): """Initializer.""" - terminal_interface_base.UI.__init__(self) + super(Win32BaseUI, self).__init__() self.encoding = 'ascii'
-class Win32CtypesUI(Win32BaseUI): +class Win32UI(terminal_interface_base.UI):
"""User interface for Win32 terminals using ctypes."""
def __init__(self): """Initializer.""" - Win32BaseUI.__init__(self) + super(Win32CtypesUI, self).__init__() (stdin, stdout, stderr, argv) = win32_unicode.get_unicode_console() self.stdin = stdin self.stdout = stdout @@ -87,7 +84,12 @@ return data.strip()
-if ctypes_found: - Win32UI = Win32CtypesUI -else: - Win32UI = Win32BaseUI +Win32CtypesUI = Win32UI + +wrapper = ModuleDeprecationWrapper(__name__) +wrapper._add_deprecated_attr('Win32CtypesUI', + replacement_name='Win32UI', + since='20190217') +wrapper._add_deprecated_attr('Win32BaseUI', + replacement_name='Win32UI', + since='20190217') diff --git a/tests/ui_tests.py b/tests/ui_tests.py index 1fbe330..a843d5e 100644 --- a/tests/ui_tests.py +++ b/tests/ui_tests.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Tests for the user interface.""" # -# (C) Pywikibot team, 2008-2018 +# (C) Pywikibot team, 2008-2019 # # Distributed under the terms of the MIT license. # @@ -834,7 +834,7 @@ net = False
expected = 'Hello world you!' - ui_class = terminal_interface_win32.Win32CtypesUI + ui_class = terminal_interface_win32.Win32UI
def setUp(self): """Patch the ctypes import and initialize a stream and UI instance."""
pywikibot-commits@lists.wikimedia.org