|
110 | 110 | import sys
|
111 | 111 | import tempfile
|
112 | 112 | import ast
|
| 113 | +from pandas.compat import zip, range, map, lmap, u, cStringIO as StringIO |
113 | 114 |
|
114 | 115 | # To keep compatibility with various python versions
|
115 | 116 | try:
|
@@ -358,6 +359,7 @@ def process_input(self, data, input_prompt, lineno):
|
358 | 359 | is_doctest = (decorator is not None and \
|
359 | 360 | decorator.startswith('@doctest')) or self.is_doctest
|
360 | 361 | is_suppress = decorator=='@suppress' or self.is_suppress
|
| 362 | + is_okexcept = decorator=='@okexcept' or self.is_okexcept |
361 | 363 | is_savefig = decorator is not None and \
|
362 | 364 | decorator.startswith('@savefig')
|
363 | 365 |
|
@@ -417,6 +419,9 @@ def process_input(self, data, input_prompt, lineno):
|
417 | 419 | elif is_semicolon: # get spacing right
|
418 | 420 | ret.append('')
|
419 | 421 |
|
| 422 | + if not is_okexcept and "Traceback" in output: |
| 423 | + sys.stdout.write(output) |
| 424 | + |
420 | 425 | self.cout.truncate(0)
|
421 | 426 | return (ret, input_lines, output, is_doctest, decorator, image_file,
|
422 | 427 | image_directive)
|
@@ -658,6 +663,7 @@ class IPythonDirective(Directive):
|
658 | 663 | 'suppress' : directives.flag,
|
659 | 664 | 'verbatim' : directives.flag,
|
660 | 665 | 'doctest' : directives.flag,
|
| 666 | + 'okexcept': directives.flag |
661 | 667 | }
|
662 | 668 |
|
663 | 669 | shell = None
|
@@ -755,6 +761,7 @@ def run(self):
|
755 | 761 | self.shell.is_suppress = 'suppress' in options
|
756 | 762 | self.shell.is_doctest = 'doctest' in options
|
757 | 763 | self.shell.is_verbatim = 'verbatim' in options
|
| 764 | + self.shell.is_okexcept = 'okexcept' in options |
758 | 765 |
|
759 | 766 | # handle pure python code
|
760 | 767 | if 'python' in self.arguments:
|
|
0 commit comments