Show More
@@ -2626,6 +2626,8 b' class InteractiveShell(SingletonConfigurable):' | |||||
2626 | result.execution_count = self.execution_count |
|
2626 | result.execution_count = self.execution_count | |
2627 |
|
2627 | |||
2628 | def error_before_exec(value): |
|
2628 | def error_before_exec(value): | |
|
2629 | if store_history: | |||
|
2630 | self.execution_count += 1 | |||
2629 | result.error_before_exec = value |
|
2631 | result.error_before_exec = value | |
2630 | self.last_execution_succeeded = False |
|
2632 | self.last_execution_succeeded = False | |
2631 | return result |
|
2633 | return result | |
@@ -2689,14 +2691,10 b' class InteractiveShell(SingletonConfigurable):' | |||||
2689 | return error_before_exec(e) |
|
2691 | return error_before_exec(e) | |
2690 | except IndentationError as e: |
|
2692 | except IndentationError as e: | |
2691 | self.showindentationerror() |
|
2693 | self.showindentationerror() | |
2692 | if store_history: |
|
|||
2693 | self.execution_count += 1 |
|
|||
2694 | return error_before_exec(e) |
|
2694 | return error_before_exec(e) | |
2695 | except (OverflowError, SyntaxError, ValueError, TypeError, |
|
2695 | except (OverflowError, SyntaxError, ValueError, TypeError, | |
2696 | MemoryError) as e: |
|
2696 | MemoryError) as e: | |
2697 | self.showsyntaxerror() |
|
2697 | self.showsyntaxerror() | |
2698 | if store_history: |
|
|||
2699 | self.execution_count += 1 |
|
|||
2700 | return error_before_exec(e) |
|
2698 | return error_before_exec(e) | |
2701 |
|
2699 | |||
2702 | # Apply AST transformations |
|
2700 | # Apply AST transformations | |
@@ -2704,8 +2702,6 b' class InteractiveShell(SingletonConfigurable):' | |||||
2704 | code_ast = self.transform_ast(code_ast) |
|
2702 | code_ast = self.transform_ast(code_ast) | |
2705 | except InputRejected as e: |
|
2703 | except InputRejected as e: | |
2706 | self.showtraceback() |
|
2704 | self.showtraceback() | |
2707 | if store_history: |
|
|||
2708 | self.execution_count += 1 |
|
|||
2709 | return error_before_exec(e) |
|
2705 | return error_before_exec(e) | |
2710 |
|
2706 | |||
2711 | # Give the displayhook a reference to our ExecutionResult so it |
|
2707 | # Give the displayhook a reference to our ExecutionResult so it |
@@ -948,3 +948,14 b' def wrn():' | |||||
948 | with tt.AssertNotPrints("I AM A WARNING"): |
|
948 | with tt.AssertNotPrints("I AM A WARNING"): | |
949 | ip.run_cell("wrn()") |
|
949 | ip.run_cell("wrn()") | |
950 | ip.run_cell("del wrn") |
|
950 | ip.run_cell("del wrn") | |
|
951 | ||||
|
952 | ||||
|
953 | def test_custom_exc_count(): | |||
|
954 | hook = mock.Mock(return_value=None) | |||
|
955 | ip.set_custom_exc((SyntaxError,), hook) | |||
|
956 | before = ip.execution_count | |||
|
957 | ip.run_cell("def foo()", store_history=True) | |||
|
958 | # restore default excepthook | |||
|
959 | ip.set_custom_exc((), None) | |||
|
960 | nt.assert_equal(hook.call_count, 1) | |||
|
961 | nt.assert_equal(ip.execution_count, before + 1) |
General Comments 0
You need to be logged in to leave comments.
Login now