From 6c856b6db40300de2ba0583bbd092b25d01b0004 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Mon, 27 Jan 2025 11:36:01 -0600 Subject: [PATCH] Fixes #284. Add UTF-8 encoding to subprocess.run in run_command Explicitly set the encoding to "utf-8" in the subprocess.run call to ensure consistent handling of command output. This prevents potential encoding-related issues when processing command results. --- bumpversion/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bumpversion/utils.py b/bumpversion/utils.py index 58c84fd1..27b23510 100644 --- a/bumpversion/utils.py +++ b/bumpversion/utils.py @@ -124,7 +124,9 @@ def format_and_raise_error(exc: Union[TypeError, subprocess.CalledProcessError]) def run_command(command: list, env: Optional[dict] = None) -> CompletedProcess: """Run a shell command and return its output.""" - result = subprocess.run(command, text=True, check=True, capture_output=True, env=env) # NOQA: S603 + result = subprocess.run( # NOQA: S603 + command, text=True, check=True, capture_output=True, env=env, encoding="utf-8" + ) result.check_returncode() return result