Show More
@@ -2626,6 +2626,8 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2626 | 2626 | result.execution_count = self.execution_count |
|
2627 | 2627 | |
|
2628 | 2628 | def error_before_exec(value): |
|
2629 | if store_history: | |
|
2630 | self.execution_count += 1 | |
|
2629 | 2631 | result.error_before_exec = value |
|
2630 | 2632 | self.last_execution_succeeded = False |
|
2631 | 2633 | return result |
@@ -2689,14 +2691,10 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2689 | 2691 | return error_before_exec(e) |
|
2690 | 2692 | except IndentationError as e: |
|
2691 | 2693 | self.showindentationerror() |
|
2692 | if store_history: | |
|
2693 | self.execution_count += 1 | |
|
2694 | 2694 | return error_before_exec(e) |
|
2695 | 2695 | except (OverflowError, SyntaxError, ValueError, TypeError, |
|
2696 | 2696 | MemoryError) as e: |
|
2697 | 2697 | self.showsyntaxerror() |
|
2698 | if store_history: | |
|
2699 | self.execution_count += 1 | |
|
2700 | 2698 | return error_before_exec(e) |
|
2701 | 2699 | |
|
2702 | 2700 | # Apply AST transformations |
@@ -2704,8 +2702,6 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2704 | 2702 | code_ast = self.transform_ast(code_ast) |
|
2705 | 2703 | except InputRejected as e: |
|
2706 | 2704 | self.showtraceback() |
|
2707 | if store_history: | |
|
2708 | self.execution_count += 1 | |
|
2709 | 2705 | return error_before_exec(e) |
|
2710 | 2706 | |
|
2711 | 2707 | # Give the displayhook a reference to our ExecutionResult so it |
@@ -948,3 +948,14 b' def wrn():' | |||
|
948 | 948 | with tt.AssertNotPrints("I AM A WARNING"): |
|
949 | 949 | ip.run_cell("wrn()") |
|
950 | 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