From ec935842ab1c2bc72d31b7c0e444600fb75ab3a5 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 27 Aug 2024 09:09:24 -0700 Subject: [PATCH] fix: Improve error handling in run_interactive_command_pexpect --- aider/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aider/utils.py b/aider/utils.py index 9c723ba98..ff296492c 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -17,11 +17,11 @@ IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".webp"} def run_interactive_command(command): try: import pexpect - - return run_interactive_command_pexpect(command) except ImportError: return run_interactive_command_subprocess(command) + return run_interactive_command_pexpect(command) + def run_interactive_command_subprocess(command): try: @@ -46,6 +46,8 @@ def run_interactive_command_pexpect(command): :param command: The command to run as a string. :return: A tuple containing (exit_status, output) """ + import pexpect + output = BytesIO() def output_callback(b): @@ -70,7 +72,6 @@ def run_interactive_command_pexpect(command): except pexpect.ExceptionPexpect as e: error_msg = f"Error running command: {e}" - print(error_msg, file=sys.stderr) return 1, error_msg