diff --git a/IPython/core/inputtransformer2.py b/IPython/core/inputtransformer2.py index 63cf1d7..afe0e00 100644 --- a/IPython/core/inputtransformer2.py +++ b/IPython/core/inputtransformer2.py @@ -636,7 +636,8 @@ class TransformerManager: MemoryError, SyntaxWarning): return 'invalid', None else: - if len(lines) > 1 and not lines[-1].strip().endswith(':'): + if len(lines) > 1 and not lines[-1].strip().endswith(':') \ + and not lines[-2][:-1].endswith('\\'): return 'incomplete', find_last_indent(lines) return 'complete', None diff --git a/IPython/core/tests/test_inputtransformer2.py b/IPython/core/tests/test_inputtransformer2.py index f78a0b3..d1ef3df 100644 --- a/IPython/core/tests/test_inputtransformer2.py +++ b/IPython/core/tests/test_inputtransformer2.py @@ -206,6 +206,7 @@ def test_check_complete(): nt.assert_equal(cc("a = '''\n hi"), ('incomplete', 3)) nt.assert_equal(cc("def a():\n x=1\n global x"), ('invalid', None)) nt.assert_equal(cc("a \\ "), ('invalid', None)) # Nothing allowed after backslash + nt.assert_equal(cc("1\\\n+2"), ('complete', None)) # no need to loop on all the letters/numbers. short = '12abAB'+string.printable[62:]