@@ -340,20 +340,14 @@ def push_accepts_more(self):
340340 This method is meant to be used by line-oriented frontends, who need to
341341 guess whether a block is complete or not based solely on prior and
342342 current input lines. The InputSplitter considers it has a complete
343- interactive block and will not accept more input only when either a
344- SyntaxError is raised, or *all* of the following are true:
345-
346- 1. The input compiles to a complete statement.
347-
348- 2. The indentation level is flush-left (because if we are indented,
349- like inside a function definition or for loop, we need to keep
350- reading new input).
343+ interactive block and will not accept more input when either:
344+
345+ * A SyntaxError is raised
351346
352- 3. There is one extra line consisting only of whitespace.
347+ * The code is complete and consists of a single line or a single
348+ non-compound statement
353349
354- Because of condition #3, this method should be used only by
355- *line-oriented* frontends, since it means that intermediate blank lines
356- are not allowed in function definitions (or any other indented block).
350+ * The code is complete and has a blank line at the end
357351
358352 If the current input produces a syntax error, this method immediately
359353 returns False but does *not* raise the syntax error exception, as
@@ -374,10 +368,13 @@ def push_accepts_more(self):
374368 #print("Blank line") # debug
375369 return False
376370
377- # If there's just a single AST node, and we're flush left, as is the
378- # case after a simple statement such as 'a=1', we want to execute it
371+ # If there's just a single line or AST node, and we're flush left, as is
372+ # the case after a simple statement such as 'a=1', we want to execute it
379373 # straight away.
380374 if self .indent_spaces == 0 :
375+ if len (self .source .splitlines ()) <= 1 :
376+ return False
377+
381378 try :
382379 code_ast = ast .parse (u'' .join (self ._buffer ))
383380 except Exception :
0 commit comments