##// END OF EJS Templates
catch NotImplementedError, not NotImplemented...
MinRK -
Show More
@@ -115,17 +115,23 b' def display(*objs, **kwargs):'
115
115
116 for obj in objs:
116 for obj in objs:
117
117
118 # If _ipython_display_ is defined, use that to display this object. If
118 # If _ipython_display_ is defined, use that to display this object.
119 # it returns NotImplemented, use the _repr_ logic (default).
119 display_method = getattr(obj, '_ipython_display_', None)
120 if not hasattr(obj, '_ipython_display_') or obj._ipython_display_(**kwargs) is NotImplemented:
120 if display_method is not None:
121 if raw:
121 try:
122 publish_display_data('display', obj, metadata)
122 display_method(**kwargs)
123 else:
123 except NotImplementedError:
124 format_dict, md_dict = format(obj, include=include, exclude=exclude)
124 pass
125 if metadata:
125 else:
126 # kwarg-specified metadata gets precedence
126 continue
127 _merge(md_dict, metadata)
127 if raw:
128 publish_display_data('display', format_dict, md_dict)
128 publish_display_data('display', obj, metadata)
129 else:
130 format_dict, md_dict = format(obj, include=include, exclude=exclude)
131 if metadata:
132 # kwarg-specified metadata gets precedence
133 _merge(md_dict, metadata)
134 publish_display_data('display', format_dict, md_dict)
129
135
130
136
131 def display_pretty(*objs, **kwargs):
137 def display_pretty(*objs, **kwargs):
@@ -241,16 +241,21 b' class DisplayHook(Configurable):'
241 """
241 """
242 self.check_for_underscore()
242 self.check_for_underscore()
243 if result is not None and not self.quiet():
243 if result is not None and not self.quiet():
244 # If _ipython_display_ is defined, use that to display this object. If
244 # If _ipython_display_ is defined, use that to display this object.
245 # it returns NotImplemented, use the _repr_ logic (default).
245 display_method = getattr(result, '_ipython_display_', None)
246 if not hasattr(result, '_ipython_display_') or result._ipython_display_() is NotImplemented:
246 if display_method is not None:
247 self.start_displayhook()
247 try:
248 self.write_output_prompt()
248 return display_method()
249 format_dict, md_dict = self.compute_format_data(result)
249 except NotImplementedError:
250 self.write_format_data(format_dict, md_dict)
250 pass
251 self.update_user_ns(result)
251
252 self.log_output(format_dict)
252 self.start_displayhook()
253 self.finish_displayhook()
253 self.write_output_prompt()
254 format_dict, md_dict = self.compute_format_data(result)
255 self.write_format_data(format_dict, md_dict)
256 self.update_user_ns(result)
257 self.log_output(format_dict)
258 self.finish_displayhook()
254
259
255 def flush(self):
260 def flush(self):
256 if not self.do_full_cache:
261 if not self.do_full_cache:
General Comments 0
You need to be logged in to leave comments. Login now