##// END OF EJS Templates
image formatters allow both bytes and unicode (b64-encoded)
MinRK -
Show More
@@ -39,7 +39,7 b' from IPython.utils.traitlets import ('
39 )
39 )
40 from IPython.utils.warn import warn
40 from IPython.utils.warn import warn
41 from IPython.utils.py3compat import (
41 from IPython.utils.py3compat import (
42 unicode_to_str, with_metaclass, PY3, string_types,
42 unicode_to_str, with_metaclass, PY3, string_types, unicode_type,
43 )
43 )
44
44
45 if PY3:
45 if PY3:
@@ -195,8 +195,8 b' def warn_format_error(method, self, *args, **kwargs):'
195 (isinstance(r, tuple) and r and isinstance(r[0], self._return_type)):
195 (isinstance(r, tuple) and r and isinstance(r[0], self._return_type)):
196 return r
196 return r
197 else:
197 else:
198 warn("%s formatter returned invalid type %s for object: %s" % (
198 warn("%s formatter returned invalid type %s (expected %s) for object: %s" % (
199 self.format_type, type(r), pretty._safe_repr(args[0])
199 self.format_type, type(r), self._return_type, pretty._safe_repr(args[0])
200 ))
200 ))
201
201
202
202
@@ -689,7 +689,7 b' class PNGFormatter(BaseFormatter):'
689
689
690 print_method = ObjectName('_repr_png_')
690 print_method = ObjectName('_repr_png_')
691
691
692 _return_type = bytes
692 _return_type = (bytes, unicode_type)
693
693
694
694
695 class JPEGFormatter(BaseFormatter):
695 class JPEGFormatter(BaseFormatter):
@@ -707,7 +707,7 b' class JPEGFormatter(BaseFormatter):'
707
707
708 print_method = ObjectName('_repr_jpeg_')
708 print_method = ObjectName('_repr_jpeg_')
709
709
710 _return_type = bytes
710 _return_type = (bytes, unicode_type)
711
711
712
712
713 class LatexFormatter(BaseFormatter):
713 class LatexFormatter(BaseFormatter):
General Comments 0
You need to be logged in to leave comments. Login now