To see this bug, start a Qt console and enter something like this (just using the return key, not ctrl-return):
a = 1
b = [1,
(at this point, you get a SyntaxError).
The trouble is codeop.CommandCompiler, the tool we use in inputsplitter to distinguish a syntax error from an incomplete cell. By default, it compiles in "single" mode, which doesn't work properly with multiple statements. This patch uses "exec" mode instead.
The documentation for codeop says that only "single" and "eval" are valid arguments, but a look at the code reveals that the argument is ultimately just passed to compile, and using "exec" works with everything I've tried throwing at it. I guess it was invalid in older versions, and the documentation hasn't been updated (the docs for codeop describe backwards compatibility with Python 2.1).
There is also a test (which fails without the patch).
Add test for inputsplitter bug.
Add exec flag so inputsplitter handles multiline cells better.
Looks good to me, go for it. Thanks!