Skip to content

Commit

Permalink
Do not use text mode for dex verify
Browse files Browse the repository at this point in the history
Summary: The output may not be UTF-8.

Reviewed By: beicy

Differential Revision: D48088405

fbshipit-source-id: af21d3782c3f5b499c6797ee7d9af4f356429f77
  • Loading branch information
agampe authored and facebook-github-bot committed Aug 8, 2023
1 parent 0f561ed commit 9327b95
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pyredex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,17 @@ def _verify_dex(dex_file: str, cmd: str) -> bool:
logging.debug("Verifying %s...", dex_file)

res = subprocess.run(
f"{cmd} '{dex_file}'", shell=True, text=True, capture_output=True
f"{cmd} '{dex_file}'", shell=True, text=False, capture_output=True
)
if res.returncode == 0:
return True

logging.error(
"Failed verification for %s:\n%s\n---\n%s", dex_file, res.stdout, res.stderr
)
try:
stderr_str = res.stderr.decode("utf-8")
except BaseException:
stderr_str = "<unable to decode, contains non-UTF8>"

logging.error("Failed verification for %s:\n%s", dex_file, stderr_str)
return False


Expand Down

0 comments on commit 9327b95

Please sign in to comment.