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