From e5e10499150e813b71a17a3d3dc7933bef3bda02 2014-01-12 21:52:13 From: Paul Ivanov Date: 2014-01-12 21:52:13 Subject: [PATCH] propagate display metadata to all mimetypes This change makes: display(SVG(s1), metadata=dict(isolated=True)) behave the same as display_svg(SVG(s1), metadata=dict(isolated=True)) --- diff --git a/IPython/core/display.py b/IPython/core/display.py index 8c7a113..36c4321 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -118,6 +118,12 @@ def display(*objs, **kwargs): for obj in objs: format_dict, md_dict = format(obj, include=include, exclude=exclude) if metadata: + # publish_display_data exepects metadata dict that is keyed by + # mimetype, so this ensures we recreate such a dict for it, if + # one is not already passed to us + if set(metadata.keys()) != set(format_dict.keys()): + _md = metadata.copy() + metadata = {mt: _md for mt in format_dict} # kwarg-specified metadata gets precedence _merge(md_dict, metadata) publish_display_data('display', format_dict, md_dict)