Skip to content

Commit

Permalink
Add errors="backslashreplace" to run_with_env_secrets.py (#5456)
Browse files Browse the repository at this point in the history
See:
https://fb.workplace.com/groups/4571909969591489/permalink/7818394354943018/

ExecuTorch CI was running into an issue where non-utf8 print output
caused tests to crash. This was resolved by removing the printing in
pytorch/executorch#4268.

This PR updates the error handling to use `backslashreplace`, which
should still show us the error/printing, but without crashing the test.

From https://docs.python.org/3.9/library/io.html#io.TextIOWrapper:
```
'backslashreplace' causes malformed data to be replaced by a backslashed escape sequence. 
```
From
https://docs.python.org/3/library/subprocess.html#frequently-used-arguments:

If encoding or errors are specified, or text (also known as
universal_newlines) is true, the file objects stdin, stdout and stderr
will be opened in text mode using the encoding and errors specified in
the call or the defaults for
[io.TextIOWrapper](https://docs.python.org/3/library/io.html#io.TextIOWrapper).
  • Loading branch information
lucylq authored Jul 23, 2024
1 parent 52eb4b5 commit 52f9014
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions .github/scripts/run_with_env_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def run_cmd_or_die(cmd):
stderr=subprocess.STDOUT,
bufsize=1,
universal_newlines=True,
errors="backslashreplace",
)
p.stdin.write("set -e\n")
p.stdin.write(cmd)
Expand Down

0 comments on commit 52f9014

Please sign in to comment.