From afe5b1c4d29d074b45883821288193148751bcd0 Mon Sep 17 00:00:00 2001 From: haddjeri Date: Tue, 26 Apr 2022 13:52:33 +0200 Subject: [PATCH] Added Unicode error correction using following Error Handler errors="surrogateescape" as discussed here https://github.com/jupyter/jupyter_client/issues/778 --- jupyter_client/session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jupyter_client/session.py b/jupyter_client/session.py index b8badcfe5..0c1a15ae6 100644 --- a/jupyter_client/session.py +++ b/jupyter_client/session.py @@ -101,7 +101,7 @@ def json_packer(obj): default=json_default, ensure_ascii=False, allow_nan=False, - ).encode("utf8") + ).encode("utf8", errors="surrogateescape") except (TypeError, ValueError) as e: # Fallback to trying to clean the json before serializing packed = json.dumps( @@ -109,7 +109,7 @@ def json_packer(obj): default=json_default, ensure_ascii=False, allow_nan=False, - ).encode("utf8") + ).encode("utf8", errors="surrogateescape") warnings.warn( f"Message serialization failed with:\n{e}\n"