diff --git a/jupyter_client/jsonutil.py b/jupyter_client/jsonutil.py index 8532cc35..db46d1b1 100644 --- a/jupyter_client/jsonutil.py +++ b/jupyter_client/jsonutil.py @@ -111,7 +111,7 @@ def json_default(obj): return obj.isoformat().replace('+00:00', 'Z') if isinstance(obj, bytes): - return b2a_base64(obj).decode('ascii') + return b2a_base64(obj, newline=False).decode('ascii') if isinstance(obj, Iterable): return list(obj) @@ -157,7 +157,7 @@ def json_clean(obj): if isinstance(obj, bytes): # unanmbiguous binary data is base64-encoded # (this probably should have happened upstream) - return b2a_base64(obj).decode('ascii') + return b2a_base64(obj, newline=False).decode('ascii') if isinstance(obj, container_to_list) or ( hasattr(obj, '__iter__') and hasattr(obj, next_attr_name) diff --git a/tests/test_jsonutil.py b/tests/test_jsonutil.py index a3074b5c..3b029fcd 100644 --- a/tests/test_jsonutil.py +++ b/tests/test_jsonutil.py @@ -166,7 +166,7 @@ def test_json_default(): (True, None), (False, None), (None, None), - ({"key": b"\xFF"}, {"key": "/w==\n"}), + ({"key": b"\xFF"}, {"key": "/w=="}), # Containers ([1, 2], None), ((1, 2), [1, 2]),