Skip to content

Commit

Permalink
Use os.device_encoding(0) to figure out stdin encoding in run_command().
Browse files Browse the repository at this point in the history
  • Loading branch information
devdanzin committed May 9, 2024
1 parent 0a6e692 commit d81f5f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import contextlib
import dis
import io
import locale
import os
import os.path
import re
Expand Down Expand Up @@ -62,7 +63,8 @@ def run_command(cmd: str) -> tuple[int, str]:
status = proc.returncode

# Get the output, and canonicalize it to strings with newlines.
output_str = output.decode(output_encoding()).replace("\r", "")
encoding = os.device_encoding(0) or locale.getpreferredencoding()
output_str = output.decode(encoding).replace("\r", "")
return status, output_str


Expand Down

0 comments on commit d81f5f3

Please sign in to comment.