From 4ece6d2a9bf7b43372ffd2b1ab3dc6845ce43f1b Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sat, 11 Jan 2025 15:40:24 -0800 Subject: [PATCH] fix: handle Text objects properly in io.py for Windows Unicode encoding --- aider/io.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aider/io.py b/aider/io.py index 269428197..dc50b4178 100644 --- a/aider/io.py +++ b/aider/io.py @@ -813,13 +813,16 @@ class InputOutput: hist = message.strip() if strip else message self.append_chat_history(hist, linebreak=True, blockquote=True) - message = Text(message) + if not isinstance(message, Text): + message = Text(message) style = dict(style=color) if self.pretty and color else dict() try: self.console.print(message, **style) except UnicodeEncodeError: # Fallback to ASCII-safe output - message = message.encode("ascii", errors="replace").decode("ascii") + if isinstance(message, Text): + message = message.plain + message = str(message).encode("ascii", errors="replace").decode("ascii") self.console.print(message, **style) def tool_error(self, message="", strip=True):