From a6c064a0825fe6698eb624dbba564c2d5f3a5803 2018-10-01 22:34:38 From: Bart Skowron Date: 2018-10-01 22:34:38 Subject: [PATCH] Fix #11334: Cannot make multi-line code blocks in ipython When codeop.compile_command() returns None it actually says "at least some part of the code was compiled successfully" which is not really important for checking if it's complete or not. Once we haven't got any errors during compilation process, we just want to check if there will be another nested block of code or not by checking a colon. --- diff --git a/IPython/core/inputtransformer2.py b/IPython/core/inputtransformer2.py index 1abd2cf..3c992d8 100644 --- a/IPython/core/inputtransformer2.py +++ b/IPython/core/inputtransformer2.py @@ -636,7 +636,7 @@ class TransformerManager: MemoryError, SyntaxWarning): return 'invalid', None else: - if res is None: + if not lines[-1].strip().endswith(':'): return 'incomplete', find_last_indent(lines) return 'complete', None