Show More
@@ -2555,14 +2555,19 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2555 | for i, node in enumerate(to_run_exec): |
|
2555 | for i, node in enumerate(to_run_exec): | |
2556 | mod = ast.Module([node]) |
|
2556 | mod = ast.Module([node]) | |
2557 | code = self.compile(mod, cell_name, "exec") |
|
2557 | code = self.compile(mod, cell_name, "exec") | |
2558 | if self.run_code(code): |
|
2558 | if self.run_code(code, flush_softspace=False): | |
2559 | return True |
|
2559 | return True | |
2560 |
|
2560 | |||
2561 | for i, node in enumerate(to_run_interactive): |
|
2561 | for i, node in enumerate(to_run_interactive): | |
2562 | mod = ast.Interactive([node]) |
|
2562 | mod = ast.Interactive([node]) | |
2563 | code = self.compile(mod, cell_name, "single") |
|
2563 | code = self.compile(mod, cell_name, "single") | |
2564 | if self.run_code(code): |
|
2564 | if self.run_code(code, flush_softspace=False): | |
2565 | return True |
|
2565 | return True | |
|
2566 | ||||
|
2567 | # Flush softspace | |||
|
2568 | if softspace(sys.stdout, 0): | |||
|
2569 | ||||
|
2570 | ||||
2566 | except: |
|
2571 | except: | |
2567 | # It's possible to have exceptions raised here, typically by |
|
2572 | # It's possible to have exceptions raised here, typically by | |
2568 | # compilation of odd code (such as a naked 'return' outside a |
|
2573 | # compilation of odd code (such as a naked 'return' outside a | |
@@ -2577,7 +2582,7 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2577 |
|
2582 | |||
2578 | return False |
|
2583 | return False | |
2579 |
|
2584 | |||
2580 | def run_code(self, code_obj): |
|
2585 | def run_code(self, code_obj, flush_softspace=True): | |
2581 | """Execute a code object. |
|
2586 | """Execute a code object. | |
2582 |
|
2587 | |||
2583 | When an exception occurs, self.showtraceback() is called to display a |
|
2588 | When an exception occurs, self.showtraceback() is called to display a | |
@@ -2589,6 +2594,8 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2589 | A compiled code object, to be executed |
|
2594 | A compiled code object, to be executed | |
2590 | post_execute : bool [default: True] |
|
2595 | post_execute : bool [default: True] | |
2591 | whether to call post_execute hooks after this particular execution. |
|
2596 | whether to call post_execute hooks after this particular execution. | |
|
2597 | flush_softspace : bool [default: True] | |||
|
2598 | whether to flush softspace, i.e., print a new line after this particular execution. | |||
2592 |
|
2599 | |||
2593 | Returns |
|
2600 | Returns | |
2594 | ------- |
|
2601 | ------- | |
@@ -2622,8 +2629,9 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2622 | self.showtraceback() |
|
2629 | self.showtraceback() | |
2623 | else: |
|
2630 | else: | |
2624 | outflag = 0 |
|
2631 | outflag = 0 | |
2625 |
if softspace |
|
2632 | if flush_softspace: | |
2626 |
|
2633 | if softspace(sys.stdout, 0): | ||
|
2634 | ||||
2627 |
|
2635 | |||
2628 | return outflag |
|
2636 | return outflag | |
2629 |
|
2637 |
General Comments 0
You need to be logged in to leave comments.
Login now