From 541d7043d7674024e489757f23ee80f3a379316f Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 9 Feb 2021 10:20:14 -0500 Subject: [PATCH] Some comments about unicode handling in this UnicodeOutput thing --- src/allmydata/windows/fixups.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/allmydata/windows/fixups.py b/src/allmydata/windows/fixups.py index bb8e3fd97..b02c63b0b 100644 --- a/src/allmydata/windows/fixups.py +++ b/src/allmydata/windows/fixups.py @@ -275,10 +275,15 @@ class UnicodeOutput(object): def write(self, text): try: if self._hConsole is None: + # There is no Windows console available. That means we are + # responsible for encoding the unicode to a byte string to + # write it to a Python file object. if isinstance(text, unicode): text = text.encode('utf-8') self._stream.write(text) else: + # There is a Windows console available. That means Windows is + # responsible for dealing with the unicode itself. if not isinstance(text, unicode): text = str(text).decode('utf-8') remaining = len(text)