Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set errors=backslashreplace #5431

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .github/scripts/run_with_env_secrets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io

Check warning

Code scanning / lintrunner

UFMT/format Warning

Run lintrunner -a to apply this patch.
import json
import os
import re
Expand All @@ -13,23 +14,25 @@
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.STDOUT,
bufsize=1,
universal_newlines=True,
bufsize=-1,
)
p.stdin.write("set -e\n")
p.stdin.write(cmd)
p.stdin.write("\nexit $?\n")
p.stdin.close()
wrapped_stdin = io.TextIOWrapper(p.stdin, encoding="utf-8", errors='backslashreplace')
wrapped_stdin.write("set -e\n")
wrapped_stdin.write(cmd)
wrapped_stdin.write("\nexit $?\n")
wrapped_stdin.flush()
wrapped_stdin.close()

wrapped_stdout = io.TextIOWrapper(p.stdout, encoding='utf-8', errors='backslashreplace')
result = ""
while p.poll() is None:
line = p.stdout.readline()
line = wrapped_stdout.readline()
if line:
print(line, end="")
result += line

# Read any remaining output
for line in p.stdout:
for line in wrapped_stdout:
print(line, end="")
result += line

Expand Down
Loading