jenkins-bot has submitted this change and it was merged.
Change subject: Unix TUI: make sure to only feed the stream acceptable characters ......................................................................
Unix TUI: make sure to only feed the stream acceptable characters
If targetStream.encoding='ascii', we cannot feed it non-ascii characters. We therefore have to encode using 'replace' (which will turn all non-ascii characters into ?'s), then decode, then feed it as unicode (py3 str) into the stream.
Then the stream will decode it again, and show it to the user.
Should fix the archiveBot test failures.
Change-Id: I1655e28b19cfe1aada0d29fd912c214b9b6de5ca --- M pywikibot/userinterfaces/terminal_interface_unix.py 1 file changed, 2 insertions(+), 1 deletion(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_unix.py b/pywikibot/userinterfaces/terminal_interface_unix.py index 915ccca..4ab6158 100755 --- a/pywikibot/userinterfaces/terminal_interface_unix.py +++ b/pywikibot/userinterfaces/terminal_interface_unix.py @@ -41,7 +41,8 @@ # just to be sure, reset the color text += unixColors['default']
- if hasattr(targetStream, 'encoding'): + if hasattr(targetStream, 'encoding') and targetStream.encoding: + text = text.encode(targetStream.encoding, 'replace').decode(targetStream.encoding) targetStream.write(text) else: targetStream.write(text.encode(self.encoding, 'replace'))