From 59ad3706115e90cd09f8b62f29f617b9d983fd20 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 30 Jul 2024 15:21:01 -0300 Subject: [PATCH] Improve linter error handling by replacing invalid characters and adding error handling for subprocess. --- aider/linter.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/aider/linter.py b/aider/linter.py index 2b663d737..cbdcee2c7 100644 --- a/aider/linter.py +++ b/aider/linter.py @@ -44,8 +44,12 @@ class Linter: cmd = cmd.split() process = subprocess.Popen( - cmd, cwd=self.root, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - encoding=self.encoding + cmd, + cwd=self.root, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding=self.encoding, + errors="replace", ) stdout, _ = process.communicate() errors = stdout @@ -141,7 +145,8 @@ class Linter: capture_output=True, text=True, check=False, - encoding=self.encoding + encoding=self.encoding, + errors="replace", ) errors = result.stdout + result.stderr except Exception as e: