Message114438
In interactive mode, multiline statements are terminated with a blank line. Your examples lacks that, so the 3rd line is part of the def and lacking the proper indent, is indeed a syntax error. You get the same with the standard command-line interpreter.
>>> def f():
... return 42
... f()
File "<stdin>", line 3
f()
^
SyntaxError: invalid syntax
That said, adding a blank line still gives a syntax error in IDLE, instead of ignoring the extra statement, while the interpreter prints 42. IDLE requires an explicit blank line from the keyboard to terminate compound statements; pasted blank lines do not count #3559 (which I now see you commented on - I should have been notified but was not).
I suspect you are correct about the dependency on code.InteractiveConsole(), but I have not looked at the IDLE code either.
In the meanwhile, either paste multiple statements in the the real interpreter or into an IDLE window and use F5 run. |
|
Date |
User |
Action |
Args |
2010-08-20 18:15:32 | terry.reedy | set | recipients:
+ terry.reedy, kbk, cben, eric.araujo |
2010-08-20 18:15:32 | terry.reedy | set | messageid: <1282328132.48.0.31513127151.issue9618@psf.upfronthosting.co.za> |
2010-08-20 18:15:30 | terry.reedy | link | issue9618 messages |
2010-08-20 18:15:29 | terry.reedy | create | |
|