##// END OF EJS Templates
Merge pull request #8493 from tianhuil/master...
Thomas Kluyver -
r21414:5131c02a merge
parent child Browse files
Show More
@@ -208,6 +208,13 b' class ExecutionResult(object):'
208 def success(self):
208 def success(self):
209 return (self.error_before_exec is None) and (self.error_in_exec is None)
209 return (self.error_before_exec is None) and (self.error_in_exec is None)
210
210
211 def raise_error(self):
212 """Reraises error if `success` is `False`, otherwise does nothing"""
213 if self.error_before_exec is not None:
214 raise self.error_before_exec
215 if self.error_in_exec is not None:
216 raise self.error_in_exec
217
211
218
212 class InteractiveShell(SingletonConfigurable):
219 class InteractiveShell(SingletonConfigurable):
213 """An enhanced, interactive shell for Python."""
220 """An enhanced, interactive shell for Python."""
@@ -2664,7 +2671,7 b' class InteractiveShell(SingletonConfigurable):'
2664 # tb offset is 2 because we wrap execfile
2671 # tb offset is 2 because we wrap execfile
2665 self.showtraceback(tb_offset=2)
2672 self.showtraceback(tb_offset=2)
2666
2673
2667 def safe_execfile_ipy(self, fname, shell_futures=False):
2674 def safe_execfile_ipy(self, fname, shell_futures=False, raise_exceptions=False):
2668 """Like safe_execfile, but for .ipy or .ipynb files with IPython syntax.
2675 """Like safe_execfile, but for .ipy or .ipynb files with IPython syntax.
2669
2676
2670 Parameters
2677 Parameters
@@ -2677,6 +2684,8 b' class InteractiveShell(SingletonConfigurable):'
2677 shell. It will both be affected by previous __future__ imports, and
2684 shell. It will both be affected by previous __future__ imports, and
2678 any __future__ imports in the code will affect the shell. If False,
2685 any __future__ imports in the code will affect the shell. If False,
2679 __future__ imports are not shared in either direction.
2686 __future__ imports are not shared in either direction.
2687 raise_exceptions : bool (False)
2688 If True raise exceptions everywhere. Meant for testing.
2680 """
2689 """
2681 fname = os.path.abspath(os.path.expanduser(fname))
2690 fname = os.path.abspath(os.path.expanduser(fname))
2682
2691
@@ -2711,14 +2720,14 b' class InteractiveShell(SingletonConfigurable):'
2711 with prepended_to_syspath(dname):
2720 with prepended_to_syspath(dname):
2712 try:
2721 try:
2713 for cell in get_cells():
2722 for cell in get_cells():
2714 # self.run_cell currently captures all exceptions
2715 # raised in user code. It would be nice if there were
2716 # versions of run_cell that did raise, so
2717 # we could catch the errors.
2718 result = self.run_cell(cell, silent=True, shell_futures=shell_futures)
2723 result = self.run_cell(cell, silent=True, shell_futures=shell_futures)
2719 if not result.success:
2724 if raise_exceptions:
2725 result.raise_error()
2726 elif not result.success:
2720 break
2727 break
2721 except:
2728 except:
2729 if raise_exceptions:
2730 raise
2722 self.showtraceback()
2731 self.showtraceback()
2723 warn('Unknown failure executing file: <%s>' % fname)
2732 warn('Unknown failure executing file: <%s>' % fname)
2724
2733
General Comments 0
You need to be logged in to leave comments. Login now