Skip to content

Commit e9ae299

Browse files
committed
Show warning after json_clean
1 parent 79d9fe4 commit e9ae299

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

jupyter_client/session.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,21 @@ def json_packer(obj):
102102
).encode("utf8")
103103
except ValueError as e:
104104
# Fallback to trying to clean the json before serializing
105+
packed = json.dumps(
106+
json_clean(obj),
107+
default=json_default,
108+
ensure_ascii=False,
109+
allow_nan=False,
110+
).encode("utf8")
111+
105112
warnings.warn(
106113
f"Message serialization failed with:\n{e}\n"
107114
"Supporting this message is deprecated in jupyter-client 7, please make "
108115
"sure your message is JSON-compliant",
109116
stacklevel=2,
110117
)
111-
return json.dumps(
112-
json_clean(obj),
113-
default=json_default,
114-
ensure_ascii=False,
115-
allow_nan=False,
116-
).encode("utf8")
118+
119+
return packed
117120

118121

119122
def json_unpacker(s):

0 commit comments

Comments
 (0)