Show More
@@ -340,20 +340,14 b' class InputSplitter(object):' | |||
|
340 | 340 | This method is meant to be used by line-oriented frontends, who need to |
|
341 | 341 | guess whether a block is complete or not based solely on prior and |
|
342 | 342 | current input lines. The InputSplitter considers it has a complete |
|
343 |
interactive block and will not accept more input |
|
|
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 | |
|
351 | 346 | |
|
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 | |
|
353 | 349 | |
|
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 | |
|
357 | 351 | |
|
358 | 352 | If the current input produces a syntax error, this method immediately |
|
359 | 353 | returns False but does *not* raise the syntax error exception, as |
@@ -374,10 +368,13 b' class InputSplitter(object):' | |||
|
374 | 368 | #print("Blank line") # debug |
|
375 | 369 | return False |
|
376 | 370 | |
|
377 |
# If there's just a single AST node, and we're flush left, as is |
|
|
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 | |
|
379 | 373 | # straight away. |
|
380 | 374 | if self.indent_spaces==0: |
|
375 | if len(self.source.splitlines()) <= 1: | |
|
376 | return False | |
|
377 | ||
|
381 | 378 | try: |
|
382 | 379 | code_ast = ast.parse(u''.join(self._buffer)) |
|
383 | 380 | except Exception: |
General Comments 0
You need to be logged in to leave comments.
Login now