##// END OF EJS Templates
Don't emit a trailng newline in base64-encoded data like 'image/png' (#13941)...
Matthias Bussonnier -
r28117:b545bcb6 merge
parent child Browse files
Show More
@@ -1042,7 +1042,7 b' class Image(DisplayObject):'
1042 def _data_and_metadata(self, always_both=False):
1042 def _data_and_metadata(self, always_both=False):
1043 """shortcut for returning metadata with shape information, if defined"""
1043 """shortcut for returning metadata with shape information, if defined"""
1044 try:
1044 try:
1045 b64_data = b2a_base64(self.data).decode('ascii')
1045 b64_data = b2a_base64(self.data, newline=False).decode("ascii")
1046 except TypeError as e:
1046 except TypeError as e:
1047 raise FileNotFoundError(
1047 raise FileNotFoundError(
1048 "No such file or directory: '%s'" % (self.data)) from e
1048 "No such file or directory: '%s'" % (self.data)) from e
@@ -1198,7 +1198,7 b' class Video(DisplayObject):'
1198 # unicode input is already b64-encoded
1198 # unicode input is already b64-encoded
1199 b64_video = video
1199 b64_video = video
1200 else:
1200 else:
1201 b64_video = b2a_base64(video).decode('ascii').rstrip()
1201 b64_video = b2a_base64(video, newline=False).decode("ascii").rstrip()
1202
1202
1203 output = """<video {0} {1} {2}>
1203 output = """<video {0} {1} {2}>
1204 <source src="data:{3};base64,{4}" type="{3}">
1204 <source src="data:{3};base64,{4}" type="{3}">
@@ -154,7 +154,7 b' def print_figure(fig, fmt="png", bbox_inches="tight", base64=False, **kwargs):'
154 if fmt == 'svg':
154 if fmt == 'svg':
155 data = data.decode('utf-8')
155 data = data.decode('utf-8')
156 elif base64:
156 elif base64:
157 data = b2a_base64(data).decode("ascii")
157 data = b2a_base64(data, newline=False).decode("ascii")
158 return data
158 return data
159
159
160 def retina_figure(fig, base64=False, **kwargs):
160 def retina_figure(fig, base64=False, **kwargs):
@@ -174,7 +174,7 b' def retina_figure(fig, base64=False, **kwargs):'
174 w, h = _pngxy(pngdata)
174 w, h = _pngxy(pngdata)
175 metadata = {"width": w//2, "height":h//2}
175 metadata = {"width": w//2, "height":h//2}
176 if base64:
176 if base64:
177 pngdata = b2a_base64(pngdata).decode("ascii")
177 pngdata = b2a_base64(pngdata, newline=False).decode("ascii")
178 return pngdata, metadata
178 return pngdata, metadata
179
179
180
180
General Comments 0
You need to be logged in to leave comments. Login now