Skip to content

Commit

Permalink
Fixes #284. Add UTF-8 encoding to subprocess.run in run_command
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
coordt committed Jan 27, 2025
1 parent 5dde40f commit 6c856b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bumpversion/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6c856b6

Please # to comment.