Skip to content

Commit afe5b1c

Browse files
committed
Added Unicode error correction using following Error Handler errors="surrogateescape"
as discussed here #778
1 parent 0fca639 commit afe5b1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

jupyter_client/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ def json_packer(obj):
101101
default=json_default,
102102
ensure_ascii=False,
103103
allow_nan=False,
104-
).encode("utf8")
104+
).encode("utf8", errors="surrogateescape")
105105
except (TypeError, ValueError) as e:
106106
# Fallback to trying to clean the json before serializing
107107
packed = json.dumps(
108108
json_clean(obj),
109109
default=json_default,
110110
ensure_ascii=False,
111111
allow_nan=False,
112-
).encode("utf8")
112+
).encode("utf8", errors="surrogateescape")
113113

114114
warnings.warn(
115115
f"Message serialization failed with:\n{e}\n"

0 commit comments

Comments
 (0)