From 8be1af872105d524816255d8c15cea1b9c17270c Mon Sep 17 00:00:00 2001 From: Christopher Toth Date: Sat, 23 Dec 2023 19:46:07 -0500 Subject: [PATCH 1/2] Use UTF-8 encoding while running commands by default This fixes issues with /run on Windows which usually manifested as encoding errors. Sample: Error running command: 'charmap' codec can't decode byte 0x9d in position 298: character maps to --- aider/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 4eacaaa1d..6e34cd66c 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -392,7 +392,7 @@ class Commands: combined_output = None try: result = subprocess.run( - args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True, encoding='utf-8', errors='replace' ) combined_output = result.stdout except Exception as e: @@ -412,7 +412,7 @@ class Commands: output=combined_output, ) return msg - + def cmd_exit(self, args): "Exit the application" sys.exit() From 5f65d5d0367407253505f7fce7f48f182006cb30 Mon Sep 17 00:00:00 2001 From: Christopher Toth Date: Fri, 29 Dec 2023 13:40:33 -0500 Subject: [PATCH 2/2] Respect --encoding instead of defaulting to UTF-8 when running commands with /run --- aider/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 6e34cd66c..1d805feef 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -392,7 +392,7 @@ class Commands: combined_output = None try: result = subprocess.run( - args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True, encoding='utf-8', errors='replace' + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True, encoding=self.io.encoding, errors='replace' ) combined_output = result.stdout except Exception as e: @@ -412,7 +412,7 @@ class Commands: output=combined_output, ) return msg - + def cmd_exit(self, args): "Exit the application" sys.exit()