From 7d42b7683c1d835478eb586419f7d89a44d2ff20 2023-02-13 05:38:30 From: Alexey Zaytsev Date: 2023-02-13 05:38:30 Subject: [PATCH] Don't emit a trailng newline in base64-encoded data like 'image/png' --- diff --git a/IPython/core/display.py b/IPython/core/display.py index 23d8636..ffa6e18 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -1042,7 +1042,7 @@ class Image(DisplayObject): def _data_and_metadata(self, always_both=False): """shortcut for returning metadata with shape information, if defined""" try: - b64_data = b2a_base64(self.data).decode('ascii') + b64_data = b2a_base64(self.data, newline=False).decode("ascii") except TypeError as e: raise FileNotFoundError( "No such file or directory: '%s'" % (self.data)) from e @@ -1198,7 +1198,7 @@ class Video(DisplayObject): # unicode input is already b64-encoded b64_video = video else: - b64_video = b2a_base64(video).decode('ascii').rstrip() + b64_video = b2a_base64(video, newline=False).decode("ascii").rstrip() output = """