Show More
@@ -2752,23 +2752,25 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2752 | 2752 | |
|
2753 | 2753 | with self.display_trap: |
|
2754 | 2754 | # Compile to bytecode |
|
2755 | ast_error = None | |
|
2755 | 2756 | try: |
|
2756 | 2757 | code_ast = compiler.ast_parse(cell, filename=cell_name) |
|
2757 | 2758 | except self.custom_exceptions as e: |
|
2758 | 2759 | etype, value, tb = sys.exc_info() |
|
2759 | 2760 | self.CustomTB(etype, value, tb) |
|
2760 |
|
|
|
2761 | ast_error = e | |
|
2761 | 2762 | except IndentationError as e: |
|
2762 | 2763 | self.showindentationerror() |
|
2763 |
|
|
|
2764 | self.execution_count += 1 | |
|
2765 | return error_before_exec(e) | |
|
2764 | ast_error = e | |
|
2766 | 2765 | except (OverflowError, SyntaxError, ValueError, TypeError, |
|
2767 | 2766 | MemoryError) as e: |
|
2768 | 2767 | self.showsyntaxerror() |
|
2768 | ast_error = e | |
|
2769 | ||
|
2770 | if ast_error is not None: | |
|
2769 | 2771 | if store_history: |
|
2770 | 2772 | self.execution_count += 1 |
|
2771 | return error_before_exec(e) | |
|
2773 | return error_before_exec(ast_error) | |
|
2772 | 2774 | |
|
2773 | 2775 | # Apply AST transformations |
|
2774 | 2776 | try: |
@@ -922,3 +922,12 b' def wrn():' | |||
|
922 | 922 | with tt.AssertNotPrints("I AM A WARNING"): |
|
923 | 923 | ip.run_cell("wrn()") |
|
924 | 924 | ip.run_cell("del wrn") |
|
925 | ||
|
926 | ||
|
927 | def test_custom_exc_count(): | |
|
928 | hook = mock.Mock(return_value=None) | |
|
929 | ip.set_custom_exc((SyntaxError,), hook) | |
|
930 | before = ip.execution_count | |
|
931 | ip.run_cell("def foo()", store_history=True) | |
|
932 | nt.assert_equal(hook.call_count, 1) | |
|
933 | nt.assert_equal(ip.execution_count, before + 1) |
General Comments 0
You need to be logged in to leave comments.
Login now