diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 79b8d20..bdf1a37 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -388,6 +388,10 @@ class InputSplitter(object): # inconsistent code/source attributes. self.code, self._is_complete = None, None + # Honor termination lines properly + if source.rstrip().endswith('\\'): + return False + self._update_indent(lines) try: self.code = self._compile(source) diff --git a/IPython/core/tests/test_inputsplitter.py b/IPython/core/tests/test_inputsplitter.py index 5e5fbd7..34f66b4 100644 --- a/IPython/core/tests/test_inputsplitter.py +++ b/IPython/core/tests/test_inputsplitter.py @@ -247,6 +247,13 @@ class InputSplitterTestCase(unittest.TestCase): isp.push('') self.assertFalse(isp.push_accepts_more()) + def test_continuation(self): + isp = self.isp + isp.push("import os, \\") + self.assertTrue(isp.push_accepts_more()) + isp.push("sys") + self.assertFalse(isp.push_accepts_more()) + def test_syntax_error(self): isp = self.isp # Syntax errors immediately produce a 'ready' block, so the invalid