Fix unhandled exception in stringification of DevOutput's result (#6592)

This commit is contained in:
Jakub Kuczys 2025-08-25 23:43:41 +02:00 committed by GitHub
parent 6c3c2e8fa7
commit 936e17338c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -158,9 +158,13 @@ class DevOutput:
output.append(self.formatted_exc)
elif self.always_include_result or self.result is not None:
try:
output.append(str(self.result))
result = str(self.result)
# ensure that the result can be encoded (GH-6485)
result.encode("utf-8")
except Exception as exc:
output.append(self.format_exception(exc))
else:
output.append(result)
return sanitize_output(self.ctx, "".join(output))
async def send(self, *, tick: bool = True) -> None: