diff --git a/crytic_compile/crytic_compile.py b/crytic_compile/crytic_compile.py index bd0a4ed6..8fb63a0e 100644 --- a/crytic_compile/crytic_compile.py +++ b/crytic_compile/crytic_compile.py @@ -547,8 +547,8 @@ def _run_custom_build(custom_build: str) -> None: with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as process: stdout_bytes, stderr_bytes = process.communicate() stdout, stderr = ( - stdout_bytes.decode(), - stderr_bytes.decode(), + stdout_bytes.decode(errors="backslashreplace"), + stderr_bytes.decode(errors="backslashreplace"), ) # convert bytestrings to unicode strings LOGGER.info(stdout) diff --git a/crytic_compile/platform/brownie.py b/crytic_compile/platform/brownie.py index a05f8b69..745df321 100755 --- a/crytic_compile/platform/brownie.py +++ b/crytic_compile/platform/brownie.py @@ -63,8 +63,8 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: ) as process: stdout_bytes, stderr_bytes = process.communicate() stdout, stderr = ( - stdout_bytes.decode(), - stderr_bytes.decode(), + stdout_bytes.decode(errors="backslashreplace"), + stderr_bytes.decode(errors="backslashreplace"), ) # convert bytestrings to unicode strings LOGGER.info(stdout) diff --git a/crytic_compile/platform/buidler.py b/crytic_compile/platform/buidler.py index 987f6561..577cc08f 100755 --- a/crytic_compile/platform/buidler.py +++ b/crytic_compile/platform/buidler.py @@ -80,8 +80,8 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: stdout_bytes, stderr_bytes = process.communicate() stdout, stderr = ( - stdout_bytes.decode(), - stderr_bytes.decode(), + stdout_bytes.decode(errors="backslashreplace"), + stderr_bytes.decode(errors="backslashreplace"), ) # convert bytestrings to unicode strings LOGGER.info(stdout) diff --git a/crytic_compile/platform/embark.py b/crytic_compile/platform/embark.py index f687608a..f81c20d6 100755 --- a/crytic_compile/platform/embark.py +++ b/crytic_compile/platform/embark.py @@ -104,10 +104,10 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: # pylint: disable=raise-missing-from raise InvalidCompilation(error) stdout, stderr = process.communicate() - LOGGER.info("%s\n", stdout.decode()) + LOGGER.info("%s\n", stdout.decode(errors="backslashreplace")) if stderr: # Embark might return information to stderr, but compile without issue - LOGGER.error("%s", stderr.decode()) + LOGGER.error("%s", stderr.decode(errors="backslashreplace")) infile = os.path.join(self._target, "crytic-export", "contracts-embark.json") if not os.path.isfile(infile): raise InvalidCompilation( diff --git a/crytic_compile/platform/etherlime.py b/crytic_compile/platform/etherlime.py index ab386c07..7504c15e 100755 --- a/crytic_compile/platform/etherlime.py +++ b/crytic_compile/platform/etherlime.py @@ -57,8 +57,8 @@ def _run_etherlime(target: str, npx_disable: bool, compile_arguments: Optional[s ) as process: stdout_bytes, stderr_bytes = process.communicate() stdout, stderr = ( - stdout_bytes.decode(), - stderr_bytes.decode(), + stdout_bytes.decode(errors="backslashreplace"), + stderr_bytes.decode(errors="backslashreplace"), ) # convert bytestrings to unicode strings LOGGER.info(stdout) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index c3e59890..228f1d14 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -87,8 +87,8 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: stdout_bytes, stderr_bytes = process.communicate() stdout, stderr = ( - stdout_bytes.decode(), - stderr_bytes.decode(), + stdout_bytes.decode(errors="backslashreplace"), + stderr_bytes.decode(errors="backslashreplace"), ) # convert bytestrings to unicode strings LOGGER.info(stdout) diff --git a/crytic_compile/platform/hardhat.py b/crytic_compile/platform/hardhat.py index dc6a9e4a..6368bb5b 100755 --- a/crytic_compile/platform/hardhat.py +++ b/crytic_compile/platform/hardhat.py @@ -79,8 +79,8 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: stdout_bytes, stderr_bytes = process.communicate() stdout, stderr = ( - stdout_bytes.decode(), - stderr_bytes.decode(), + stdout_bytes.decode(errors="backslashreplace"), + stderr_bytes.decode(errors="backslashreplace"), ) # convert bytestrings to unicode strings LOGGER.info(stdout) @@ -308,7 +308,7 @@ def _run_hardhat_console(self, base_cmd: List[str], command: str) -> Optional[st stdout_bytes, stderr_bytes = process.communicate(command.encode("utf-8")) stdout, stderr = ( stdout_bytes.decode(), - stderr_bytes.decode(), + stderr_bytes.decode(errors="backslashreplace"), ) if stderr: diff --git a/crytic_compile/platform/solc_standard_json.py b/crytic_compile/platform/solc_standard_json.py index d64f5b0a..ab500458 100644 --- a/crytic_compile/platform/solc_standard_json.py +++ b/crytic_compile/platform/solc_standard_json.py @@ -157,7 +157,7 @@ def run_solc_standard_json( stdout_b, stderr_b = process.communicate(json.dumps(solc_input).encode("utf-8")) stdout, stderr = ( stdout_b.decode(), - stderr_b.decode(), + stderr_b.decode(errors="backslashreplace"), ) # convert bytestrings to unicode strings solc_json_output = json.loads(stdout) diff --git a/crytic_compile/platform/truffle.py b/crytic_compile/platform/truffle.py index 946fcba2..202b2ae4 100755 --- a/crytic_compile/platform/truffle.py +++ b/crytic_compile/platform/truffle.py @@ -176,8 +176,8 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: stdout_bytes, stderr_bytes = process.communicate() stdout, stderr = ( - stdout_bytes.decode(), - stderr_bytes.decode(), + stdout_bytes.decode(errors="backslashreplace"), + stderr_bytes.decode(errors="backslashreplace"), ) # convert bytestrings to unicode strings if truffle_overwrite_config: diff --git a/crytic_compile/platform/waffle.py b/crytic_compile/platform/waffle.py index 57841e05..280d5d31 100755 --- a/crytic_compile/platform/waffle.py +++ b/crytic_compile/platform/waffle.py @@ -160,9 +160,9 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: ) as process: stdout, stderr = process.communicate() if stdout: - LOGGER.info(stdout.decode()) + LOGGER.info(stdout.decode(errors="backslashreplace")) if stderr: - LOGGER.error(stderr.decode()) + LOGGER.error(stderr.decode(errors="backslashreplace")) except OSError as error: # pylint: disable=raise-missing-from raise InvalidCompilation(error) diff --git a/crytic_compile/utils/subprocess.py b/crytic_compile/utils/subprocess.py index ef34e215..dd2dd0bc 100644 --- a/crytic_compile/utils/subprocess.py +++ b/crytic_compile/utils/subprocess.py @@ -58,7 +58,10 @@ def run( LOGGER.error("Could not execute `%s`, is it installed and in PATH?", cmd[0]) except subprocess.CalledProcessError as e: LOGGER.error("'%s' returned non-zero exit code %d", cmd[0], e.returncode) - stdout, stderr = (e.stdout.decode().strip(), e.stderr.decode().strip()) + stdout, stderr = ( + e.stdout.decode(errors="backslashreplace").strip(), + e.stderr.decode(errors="backslashreplace").strip(), + ) if stdout: LOGGER.error("\nstdout: ".join(stdout.split("\n"))) if stderr: