Skip to content

Commit 4fed03a

Browse files
author
y-p
committed
BLD: ipython_directive, add back okexcept
1 parent f799be9 commit 4fed03a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

doc/sphinxext/ipython_directive.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
import sys
111111
import tempfile
112112
import ast
113+
from pandas.compat import zip, range, map, lmap, u, cStringIO as StringIO
113114

114115
# To keep compatibility with various python versions
115116
try:
@@ -358,6 +359,7 @@ def process_input(self, data, input_prompt, lineno):
358359
is_doctest = (decorator is not None and \
359360
decorator.startswith('@doctest')) or self.is_doctest
360361
is_suppress = decorator=='@suppress' or self.is_suppress
362+
is_okexcept = decorator=='@okexcept' or self.is_okexcept
361363
is_savefig = decorator is not None and \
362364
decorator.startswith('@savefig')
363365

@@ -417,6 +419,9 @@ def process_input(self, data, input_prompt, lineno):
417419
elif is_semicolon: # get spacing right
418420
ret.append('')
419421

422+
if not is_okexcept and "Traceback" in output:
423+
sys.stdout.write(output)
424+
420425
self.cout.truncate(0)
421426
return (ret, input_lines, output, is_doctest, decorator, image_file,
422427
image_directive)
@@ -658,6 +663,7 @@ class IPythonDirective(Directive):
658663
'suppress' : directives.flag,
659664
'verbatim' : directives.flag,
660665
'doctest' : directives.flag,
666+
'okexcept': directives.flag
661667
}
662668

663669
shell = None
@@ -755,6 +761,7 @@ def run(self):
755761
self.shell.is_suppress = 'suppress' in options
756762
self.shell.is_doctest = 'doctest' in options
757763
self.shell.is_verbatim = 'verbatim' in options
764+
self.shell.is_okexcept = 'okexcept' in options
758765

759766
# handle pure python code
760767
if 'python' in self.arguments:

0 commit comments

Comments
 (0)