Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't emit a trailng newline in base64-encoded data like 'image/png' #931

Merged
merged 2 commits into from
Feb 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Don't emit a trailng newline in base64-encoded data like 'image/png'
  • Loading branch information
xl0 committed Feb 12, 2023
commit eda2b565b009448ebd82a2b648c6589cdccd142c
4 changes: 2 additions & 2 deletions jupyter_client/jsonutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down