Skip to content

Commit 6c856b6

Browse files
committed
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.
1 parent 5dde40f commit 6c856b6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bumpversion/utils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def format_and_raise_error(exc: Union[TypeError, subprocess.CalledProcessError])
124124

125125
def run_command(command: list, env: Optional[dict] = None) -> CompletedProcess:
126126
"""Run a shell command and return its output."""
127-
result = subprocess.run(command, text=True, check=True, capture_output=True, env=env) # NOQA: S603
127+
result = subprocess.run( # NOQA: S603
128+
command, text=True, check=True, capture_output=True, env=env, encoding="utf-8"
129+
)
128130
result.check_returncode()
129131
return result
130132

0 commit comments

Comments
 (0)