Show More
@@ -2752,23 +2752,25 class InteractiveShell(SingletonConfigurable): | |||||
2752 |
|
2752 | |||
2753 | with self.display_trap: |
|
2753 | with self.display_trap: | |
2754 | # Compile to bytecode |
|
2754 | # Compile to bytecode | |
|
2755 | ast_error = None | |||
2755 | try: |
|
2756 | try: | |
2756 | code_ast = compiler.ast_parse(cell, filename=cell_name) |
|
2757 | code_ast = compiler.ast_parse(cell, filename=cell_name) | |
2757 | except self.custom_exceptions as e: |
|
2758 | except self.custom_exceptions as e: | |
2758 | etype, value, tb = sys.exc_info() |
|
2759 | etype, value, tb = sys.exc_info() | |
2759 | self.CustomTB(etype, value, tb) |
|
2760 | self.CustomTB(etype, value, tb) | |
2760 |
|
|
2761 | ast_error = e | |
2761 | except IndentationError as e: |
|
2762 | except IndentationError as e: | |
2762 | self.showindentationerror() |
|
2763 | self.showindentationerror() | |
2763 |
|
|
2764 | ast_error = e | |
2764 | self.execution_count += 1 |
|
|||
2765 | return error_before_exec(e) |
|
|||
2766 | except (OverflowError, SyntaxError, ValueError, TypeError, |
|
2765 | except (OverflowError, SyntaxError, ValueError, TypeError, | |
2767 | MemoryError) as e: |
|
2766 | MemoryError) as e: | |
2768 | self.showsyntaxerror() |
|
2767 | self.showsyntaxerror() | |
|
2768 | ast_error = e | |||
|
2769 | ||||
|
2770 | if ast_error is not None: | |||
2769 | if store_history: |
|
2771 | if store_history: | |
2770 | self.execution_count += 1 |
|
2772 | self.execution_count += 1 | |
2771 | return error_before_exec(e) |
|
2773 | return error_before_exec(ast_error) | |
2772 |
|
2774 | |||
2773 | # Apply AST transformations |
|
2775 | # Apply AST transformations | |
2774 | try: |
|
2776 | try: |
@@ -922,3 +922,12 def wrn(): | |||||
922 | with tt.AssertNotPrints("I AM A WARNING"): |
|
922 | with tt.AssertNotPrints("I AM A WARNING"): | |
923 | ip.run_cell("wrn()") |
|
923 | ip.run_cell("wrn()") | |
924 | ip.run_cell("del wrn") |
|
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