mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
fix: handle Text objects properly in io.py for Windows Unicode encoding
This commit is contained in:
parent
18d1d7af33
commit
4ece6d2a9b
1 changed files with 5 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue