From 052280d4e942bbfdcccd028c9726db1282c511e6 2014-01-25 15:53:51 From: y-p Date: 2014-01-25 15:53:51 Subject: [PATCH] Guard against self.state is None --- diff --git a/IPython/sphinxext/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index 1ea6ea8..6c29a89 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -429,8 +429,11 @@ class EmbeddedSphinxShell(object): ret.append('') # context information - filename = self.state.document.current_source - lineno = self.state.document.current_line + filename = "Unknown" + lineno = 0 + if self.state: + filename = self.state.document.current_source + lineno = self.state.document.current_line # output any exceptions raised during execution to stdout # unless :okexcept: has been specified.