Show More
@@ -446,11 +446,11 b' class InputSplitter(object):' | |||
|
446 | 446 | return False |
|
447 | 447 | else: |
|
448 | 448 | try: |
|
449 |
|
|
|
449 | code_ast = ast.parse(u''.join(self._buffer)) | |
|
450 | 450 | except Exception: |
|
451 | 451 | return False |
|
452 | 452 | else: |
|
453 |
if len( |
|
|
453 | if len(code_ast.body) == 1: | |
|
454 | 454 | return False |
|
455 | 455 | |
|
456 | 456 | # When input is complete, then termination is marked by an extra blank |
@@ -539,23 +539,6 b' class InputSplitter(object):' | |||
|
539 | 539 | # python syntax, feed it back a second time through the AST-based |
|
540 | 540 | # splitter, which is more accurate than ours. |
|
541 | 541 | return split_blocks(''.join(blocks)) |
|
542 | ||
|
543 | def ast_nodes(self, lines=None): | |
|
544 | """Turn the lines into a list of AST nodes. | |
|
545 | ||
|
546 | Parameters | |
|
547 | ---------- | |
|
548 | lines : str | |
|
549 | A (possibly multiline) string of Python code. If None (default), it | |
|
550 | will use the InputSplitter's current code buffer. | |
|
551 | ||
|
552 | Returns | |
|
553 | ------- | |
|
554 | A list of AST (abstract syntax tree) nodes representing the code. | |
|
555 | """ | |
|
556 | if lines is None: | |
|
557 | lines = u"".join(self._buffer) | |
|
558 | return ast.parse(lines).body | |
|
559 | 542 | |
|
560 | 543 | #------------------------------------------------------------------------ |
|
561 | 544 | # Private interface |
@@ -2125,7 +2125,7 b' class InteractiveShell(Configurable, Magic):' | |||
|
2125 | 2125 | |
|
2126 | 2126 | with self.display_trap: |
|
2127 | 2127 | try: |
|
2128 |
|
|
|
2128 | code_ast = ast.parse(cell) | |
|
2129 | 2129 | except (OverflowError, SyntaxError, ValueError, TypeError, MemoryError): |
|
2130 | 2130 | # Case 1 |
|
2131 | 2131 | self.showsyntaxerror(filename) |
@@ -2135,7 +2135,7 b' class InteractiveShell(Configurable, Magic):' | |||
|
2135 | 2135 | if len(cell.splitlines()) == 1: |
|
2136 | 2136 | interactivity = 2 # Single line; run fully interactive |
|
2137 | 2137 | |
|
2138 |
self.run_ast_nodes( |
|
|
2138 | self.run_ast_nodes(code_ast.body, interactivity) | |
|
2139 | 2139 | |
|
2140 | 2140 | if store_history: |
|
2141 | 2141 | # Write output to the database. Does nothing unless |
General Comments 0
You need to be logged in to leave comments.
Login now