Skip to content

Commit

Permalink
Added Unicode error correction using following Error Handler errors="…
Browse files Browse the repository at this point in the history
…surrogateescape"

as discussed here #778
  • Loading branch information
H3xawax committed Apr 26, 2022
1 parent 0fca639 commit afe5b1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jupyter_client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ 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(
json_clean(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"
Expand Down

0 comments on commit afe5b1c

Please sign in to comment.