jenkins-bot has submitted this change and it was merged.
Change subject: Win32 input for py3: streams are unicode not bytes
......................................................................
Win32 input for py3: streams are unicode not bytes
On Python 2, streams are bytes, so the unicode data returned from the
win32 api needs to be encoded (as utf-8, in this case). In Python 3,
this is all unicode, so we need to skip the encoding step.
Decoding works OK due to the 'if isinstance(x, unicode)' blocks.
Bug: T76236
Change-Id: I4121ac87816b144e334e7e47c61ce445f0b6e2c9
---
M pywikibot/userinterfaces/win32_unicode.py
1 file changed, 8 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/win32_unicode.py
b/pywikibot/userinterfaces/win32_unicode.py
index b92b273..dc85cc2 100755
--- a/pywikibot/userinterfaces/win32_unicode.py
+++ b/pywikibot/userinterfaces/win32_unicode.py
@@ -28,6 +28,9 @@
if sys.version_info[0] > 2:
unicode = str
+ PY3 = True
+else:
+ PY3 = False
if sys.platform == "win32":
import codecs
@@ -137,7 +140,11 @@
result = ReadConsoleW(self._hConsole, self.buffer, maxnum,
byref(numrecv), None)
if not result:
raise Exception("stdin failure")
- return self.buffer.value[:numrecv.value].encode(self.encoding)
+ data = self.buffer.value[:numrecv.value]
+ if not PY3:
+ return data.encode(self.encoding)
+ else:
+ return data
if real_stdout or real_stderr:
# BOOL WINAPI WriteConsoleW(HANDLE hOutput, LPWSTR lpBuffer, DWORD nChars,
--
To view, visit
https://gerrit.wikimedia.org/r/176371
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4121ac87816b144e334e7e47c61ce445f0b6e2c9
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>