Skip to content

Commit 7b00a74

Browse files
authored
Merge pull request #66 from ImogenBits/io_encoding
Gracefully handle unicode encoding errors
2 parents 321b8a5 + 24c60d4 commit 7b00a74

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

algobattle/match.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _build(self, teams: list, cache_docker_containers=True) -> bool:
184184
stderr=subprocess.PIPE, creationflags=creationflags) as process:
185185
try:
186186
output, _ = process.communicate(timeout=self.timeout_build)
187-
logger.debug(output.decode())
187+
logger.debug(output.decode(errors="ignore"))
188188
except subprocess.TimeoutExpired:
189189
process.kill()
190190
process.wait()

algobattle/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def encode(self, input: any) -> bytes:
109109
bytes
110110
Returns the input as a byte object.
111111
"""
112-
return "\n".join(str(" ".join(str(element) for element in line)) for line in input).encode()
112+
return "\n".join(str(" ".join(str(element) for element in line)) for line in input).encode(errors="ignore")
113113

114114
@abstractmethod
115115
def decode(self, raw_input: bytes) -> any:
@@ -129,4 +129,4 @@ def decode(self, raw_input: bytes) -> any:
129129
any
130130
Returns the decoded input.
131131
"""
132-
return [tuple(line.split()) for line in raw_input.decode().splitlines() if line.split()]
132+
return [tuple(line.split()) for line in raw_input.decode(errors="ignore").splitlines() if line.split()]

0 commit comments

Comments
 (0)