jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Win32 UI: Don't encode in Python 3 ......................................................................
[FIX] Win32 UI: Don't encode in Python 3
The text has to be encoded for the streams in Python 2, but in Python 3 the streams like sys.stdout are working on Unicode strings.
Bug: T91921 Change-Id: I20480388fecc5dd0d476ce7896a5e5d410391270 --- M pywikibot/userinterfaces/terminal_interface_win32.py 1 file changed, 8 insertions(+), 2 deletions(-)
Approvals: Mpaa: Looks good to me, approved Dalba: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_win32.py b/pywikibot/userinterfaces/terminal_interface_win32.py index 7e3fd89..7c0dd98 100755 --- a/pywikibot/userinterfaces/terminal_interface_win32.py +++ b/pywikibot/userinterfaces/terminal_interface_win32.py @@ -8,6 +8,7 @@ __version__ = '$Id$'
import re +import sys from . import terminal_interface_base
try: @@ -72,7 +73,10 @@ tagM = colorTagR.search(text) if tagM: # print the text up to the tag. - targetStream.write(text[:tagM.start()].encode(self.encoding, 'replace')) + text_before_tag = text[:tagM.start()] + if sys.version_info[0] == 2: + text_before_tag = text_before_tag.encode(self.encoding, 'replace') + targetStream.write(text_before_tag) newColor = tagM.group('name') if newColor == 'default': if len(colorStack) > 0: @@ -88,7 +92,9 @@ ctypes.windll.kernel32.SetConsoleTextAttribute(std_out_handle, windowsColors[newColor]) text = text[tagM.end():] # print the rest of the text - targetStream.write(text.encode(self.encoding, 'replace')) + if sys.version_info[0] == 2: + text = text.encode(self.encoding, 'replace') + targetStream.write(text) # just to be sure, reset the color ctypes.windll.kernel32.SetConsoleTextAttribute(std_out_handle, windowsColors['default'])
pywikibot-commits@lists.wikimedia.org