##// END OF EJS Templates
short error message on AliasError in run_cell...
MinRK -
Show More
@@ -38,7 +38,7 b' from IPython.core import page'
38 38 from IPython.core import prefilter
39 39 from IPython.core import shadowns
40 40 from IPython.core import ultratb
41 from IPython.core.alias import AliasManager
41 from IPython.core.alias import AliasManager, AliasError
42 42 from IPython.core.autocall import ExitAutocall
43 43 from IPython.core.builtin_trap import BuiltinTrap
44 44 from IPython.core.compilerop import CachingCompiler
@@ -2129,21 +2129,17 b' class InteractiveShell(Configurable, Magic):'
2129 2129 cell = self.input_splitter.source_reset()
2130 2130
2131 2131 with self.builtin_trap:
2132 prefilter_failed = False
2132 2133 if len(cell.splitlines()) == 1:
2133 2134 try:
2134 2135 cell = self.prefilter_manager.prefilter_lines(cell)
2136 except AliasError as e:
2137 error(e)
2138 prefilter_failed=True
2135 2139 except Exception:
2136 # don't allow prefilter errors to crash IPython, because
2137 # user code can be involved (e.g. aliases)
2140 # don't allow prefilter errors to crash IPython
2138 2141 self.showtraceback()
2139 if store_history:
2140 self.history_manager.store_inputs(self.execution_count,
2141 cell, raw_cell)
2142
2143 self.logger.log(cell, raw_cell)
2144 self.execution_count += 1
2145
2146 return
2142 prefilter_failed = True
2147 2143
2148 2144 # Store raw and processed history
2149 2145 if store_history:
@@ -2152,6 +2148,8 b' class InteractiveShell(Configurable, Magic):'
2152 2148
2153 2149 self.logger.log(cell, raw_cell)
2154 2150
2151 if not prefilter_failed:
2152 # don't run if prefilter failed
2155 2153 cell_name = self.compile.cache(cell, self.execution_count)
2156 2154
2157 2155 with self.display_trap:
@@ -20,7 +20,10 b' Authors'
20 20 #-----------------------------------------------------------------------------
21 21 # stdlib
22 22 import unittest
23 from cStringIO import StringIO
24
23 25 from IPython.testing import decorators as dec
26 from IPython.utils import io
24 27
25 28 #-----------------------------------------------------------------------------
26 29 # Tests
@@ -96,4 +99,11 b' class InteractiveShellTestCase(unittest.TestCase):'
96 99 """Errors in prefilter can't crash IPython"""
97 100 ip = get_ipython()
98 101 ip.run_cell('%alias parts echo first %s second %s')
102 # capture stderr:
103 save_err = io.stderr
104 io.stderr = StringIO()
99 105 ip.run_cell('parts 1')
106 err = io.stderr.getvalue()
107 io.stderr = save_err
108 self.assertEquals(err.split(':')[0], 'ERROR')
109
General Comments 0
You need to be logged in to leave comments. Login now