diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 97c199d..7c4e75e 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -535,8 +535,15 @@ class IPythonInputSplitter(InputSplitter): self.source_raw = '' self.transformer_accumulating = False self.within_python_line = False + + last_exc = None for t in self.transforms: - t.reset() + try: + t.reset() + except SyntaxError as e: + last_exc = e + if last_exc is not None: + raise last_exc def flush_transformers(self): def _flush(transform, out): diff --git a/IPython/qt/console/frontend_widget.py b/IPython/qt/console/frontend_widget.py index acd3b49..79425b0 100644 --- a/IPython/qt/console/frontend_widget.py +++ b/IPython/qt/console/frontend_widget.py @@ -204,8 +204,14 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): prompt created. When triggered by an Enter/Return key press, 'interactive' is True; otherwise, it is False. """ - self._input_splitter.reset() - complete = self._input_splitter.push(source) + try: + self._input_splitter.reset() + except SyntaxError: + pass + try: + complete = self._input_splitter.push(source) + except SyntaxError: + return True if interactive: complete = not self._input_splitter.push_accepts_more() return complete @@ -233,7 +239,10 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): """ # Flush all state from the input splitter so the next round of # reading input starts with a clean buffer. - self._input_splitter.reset() + try: + self._input_splitter.reset() + except SyntaxError: + pass if not self._reading: self._highlighter.highlighting_on = False