From 46d3d76eac6663dff941bb83e41ac6d39d57bd94 2015-06-20 16:54:07 From: Min RK Date: 2015-06-20 16:54:07 Subject: [PATCH] Backport PR #8405: FIX : flip atexit registration Register the sphinx spcefic atexit function before InteractiveShell can register it's clean up function. The functions are executed last-in, first-out which means in this case the temporary profile directory is deleted before the final history writing can be done which results in exceptions/warnings coming out of sphinx. --- diff --git a/IPython/sphinxext/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index 3e8ca44..11ca681 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -296,8 +296,8 @@ class EmbeddedSphinxShell(object): # Create and initialize global ipython, but don't start its mainloop. # This will persist across different EmbededSphinxShell instances. - IP = InteractiveShell.instance(config=config, profile_dir=profile) atexit.register(self.cleanup) + IP = InteractiveShell.instance(config=config, profile_dir=profile) # io.stdout redirect must be done after instantiating InteractiveShell io.stdout = self.cout