Repository: ipython/ipython

Issue:
7.10 breaking tests with exception  in publish
The new 7.10 release is breaking Bokeh unit tests with an exception coming from within ipython:
```

self = <IPython.core.displaypub.DisplayPublisher object at 0x11883d7f0>
data = {'text/html': '\n    <div class="bk-root">\n        <a href="https://bokeh.org" target="_blank" class="bk-logo bk-logo...version \'1.0\' from Bokeh development version \'1.0-1-abc\'. This configuration is unsupported and may not work!</p>'}
metadata = None, source = None, transient = None, update = False, kwargs = {}
handlers = {}

<< omitted >>

        handlers = {}
        if self.shell is not None:
>           handlers = self.shell.mime_renderers
E           AttributeError: 'InteractiveShell' object has no attribute 'mime_renderers'

../miniconda/envs/testenv/lib/python3.6/site-packages/IPython/core/displaypub.py:108: AttributeError
```

Is this an intentional change (documented anwhere?) or a regression/bug?

cc @Carreau 


Discussion:
Do you have a full traceback ? 
I have this:
```

2019-11-29T18:51:45.0967290Z =================================== FAILURES ===================================
2019-11-29T18:51:45.0986970Z ______________________________ test_show_with_app ______________________________
2019-11-29T18:51:45.0987390Z 
2019-11-29T18:51:45.0988730Z mock_run_notebook_hook = <MagicMock name='run_notebook_hook' id='4706267432'>
2019-11-29T18:51:45.0989720Z ipython = <module 'IPython' from '/Users/runner/runners/2.161.0/work/bokeh/miniconda/envs/testenv/lib/python3.6/site-packages/IPython/__init__.py'>
2019-11-29T18:51:45.0990110Z 
2019-11-29T18:51:45.0990880Z     @patch('bokeh.io.showing.run_notebook_hook')
2019-11-29T18:51:45.0998410Z     def test_show_with_app(mock_run_notebook_hook, ipython):
2019-11-29T18:51:45.0998820Z         curstate().reset()
2019-11-29T18:51:45.0999150Z         app = Application()
2019-11-29T18:51:45.1007140Z >       output_notebook()
2019-11-29T18:51:45.1007530Z 
2019-11-29T18:51:45.1007880Z tests/unit/bokeh/io/test_showing.py:64: 
2019-11-29T18:51:45.1008230Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2019-11-29T18:51:45.1008740Z bokeh/io/output.py:111: in output_notebook
2019-11-29T18:51:45.1009780Z     run_notebook_hook(notebook_type, 'load', resources, verbose, hide_banner, load_timeout)
2019-11-29T18:51:45.1010220Z bokeh/io/notebook.py:298: in run_notebook_hook
2019-11-29T18:51:45.1010560Z     return _HOOKS[notebook_type][action](*args, **kw)
2019-11-29T18:51:45.1010900Z bokeh/io/notebook.py:415: in load_notebook
2019-11-29T18:51:45.1011670Z     publish_display_data({'text/html': html})
2019-11-29T18:51:45.1012090Z bokeh/io/notebook.py:427: in publish_display_data
2019-11-29T18:51:45.1012440Z     return publish_display_data(*args, **kw)
2019-11-29T18:51:45.1013210Z ../miniconda/envs/testenv/lib/python3.6/site-packages/IPython/core/display.py:122: in publish_display_data
2019-11-29T18:51:45.1013640Z     **kwargs
2019-11-29T18:51:45.1014000Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2019-11-29T18:51:45.1014280Z 
2019-11-29T18:51:45.1014630Z self = <IPython.core.displaypub.DisplayPublisher object at 0x11883d7f0>
2019-11-29T18:51:45.1015600Z data = {'text/html': '\n    <div class="bk-root">\n        <a href="https://bokeh.org" target="_blank" class="bk-logo bk-logo...version \'1.0\' from Bokeh development version \'1.0-1-abc\'. This configuration is unsupported and may not work!</p>'}
2019-11-29T18:51:45.1016070Z metadata = None, source = None, transient = None, update = False, kwargs = {}
2019-11-29T18:51:45.1016440Z handlers = {}
2019-11-29T18:51:45.1016720Z 
2019-11-29T18:51:45.1017510Z     def publish(self, data, metadata=None, source=None, *, transient=None, update=False, **kwargs) -> None:
2019-11-29T18:51:45.1017940Z         """Publish data and metadata to all frontends.
2019-11-29T18:51:45.1018280Z     
2019-11-29T18:51:45.1018620Z         See the ``display_data`` message in the messaging documentation for
2019-11-29T18:51:45.1018970Z         more details about this message type.
2019-11-29T18:51:45.1019300Z     
2019-11-29T18:51:45.1019630Z         The following MIME types are currently implemented:
2019-11-29T18:51:45.1020070Z     
2019-11-29T18:51:45.1020480Z         * text/plain
2019-11-29T18:51:45.1020820Z         * text/html
2019-11-29T18:51:45.1021160Z         * text/markdown
2019-11-29T18:51:45.1021570Z         * text/latex
2019-11-29T18:51:45.1021970Z         * application/json
2019-11-29T18:51:45.1022320Z         * application/javascript
2019-11-29T18:51:45.1023260Z         * image/png
2019-11-29T18:51:45.1023690Z         * image/jpeg
2019-11-29T18:51:45.1024020Z         * image/svg+xml
2019-11-29T18:51:45.1024350Z     
2019-11-29T18:51:45.1024670Z         Parameters
2019-11-29T18:51:45.1025390Z         ----------
2019-11-29T18:51:45.1025800Z         data : dict
2019-11-29T18:51:45.1127250Z             A dictionary having keys that are valid MIME types (like
2019-11-29T18:51:45.1232160Z             'text/plain' or 'image/svg+xml') and values that are the data for
2019-11-29T18:51:45.1241770Z             that MIME type. The data itself must be a JSON'able data
2019-11-29T18:51:45.1560060Z             structure. Minimally all data should have the 'text/plain' data,
2019-11-29T18:51:45.1568440Z             which can be displayed by all frontends. If more than the plain
2019-11-29T18:51:45.2085240Z             text is given, it is up to the frontend to decide which
2019-11-29T18:51:45.2194410Z             representation to use.
2019-11-29T18:51:45.2307050Z         metadata : dict
2019-11-29T18:51:45.2440280Z             A dictionary for metadata related to the data. This can contain
2019-11-29T18:51:45.2500960Z             arbitrary key, value pairs that frontends can use to interpret
2019-11-29T18:51:45.2604570Z             the data.  Metadata specific to each mime-type can be specified
2019-11-29T18:51:45.2711190Z             in the metadata dict with the same mime-type keys as
2019-11-29T18:51:45.2811370Z             the data itself.
2019-11-29T18:51:45.2912590Z         source : str, deprecated
2019-11-29T18:51:45.3013120Z             Unused.
2019-11-29T18:51:45.3115140Z         transient: dict, keyword-only
2019-11-29T18:51:45.3214970Z             A dictionary for transient data.
2019-11-29T18:51:45.3316080Z             Data in this dictionary should not be persisted as part of saving this output.
2019-11-29T18:51:45.3417560Z             Examples include 'display_id'.
2019-11-29T18:51:45.3501830Z         update: bool, keyword-only, default: False
2019-11-29T18:51:45.3557880Z             If True, only update existing outputs with the same display_id,
2019-11-29T18:51:45.3668770Z             rather than creating a new output.
2019-11-29T18:51:45.3729450Z         """
2019-11-29T18:51:45.3786230Z     
2019-11-29T18:51:45.3837840Z         handlers = {}
2019-11-29T18:51:45.3847990Z         if self.shell is not None:
2019-11-29T18:51:45.3872540Z >           handlers = self.shell.mime_renderers
2019-11-29T18:51:45.3893820Z E           AttributeError: 'InteractiveShell' object has no attribute 'mime_renderers'
2019-11-29T18:51:45.3907050Z 
2019-11-29T18:51:45.3927320Z ../miniconda/envs/testenv/lib/python3.6/site-packages/IPython/core/displaypub.py:108: AttributeError
2019-11-29T18:51:45.4020830Z =============================== warnings summary ===============================

```

Resolving patch:
diff --git a/IPython/core/displaypub.py b/IPython/core/displaypub.py
--- a/IPython/core/displaypub.py
+++ b/IPython/core/displaypub.py
@@ -105,7 +105,7 @@ def publish(self, data, metadata=None, source=None, *, transient=None, update=Fa
 
         handlers = {}
         if self.shell is not None:
-            handlers = self.shell.mime_renderers
+            handlers = getattr(self.shell, 'mime_renderers', {})
 
         for mime, handler in handlers.items():
             if mime in data:


Test patch: