Show More
@@ -1604,7 +1604,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
1604 | self.InteractiveTB.set_mode(mode=self.xmode) |
|
1604 | self.InteractiveTB.set_mode(mode=self.xmode) | |
1605 |
|
1605 | |||
1606 | def set_custom_exc(self, exc_tuple, handler): |
|
1606 | def set_custom_exc(self, exc_tuple, handler): | |
1607 | """set_custom_exc(exc_tuple,handler) |
|
1607 | """set_custom_exc(exc_tuple, handler) | |
1608 |
|
1608 | |||
1609 | Set a custom exception handler, which will be called if any of the |
|
1609 | Set a custom exception handler, which will be called if any of the | |
1610 | exceptions in exc_tuple occur in the mainloop (specifically, in the |
|
1610 | exceptions in exc_tuple occur in the mainloop (specifically, in the | |
@@ -1647,7 +1647,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
1647 | assert type(exc_tuple)==type(()) , \ |
|
1647 | assert type(exc_tuple)==type(()) , \ | |
1648 | "The custom exceptions must be given AS A TUPLE." |
|
1648 | "The custom exceptions must be given AS A TUPLE." | |
1649 |
|
1649 | |||
1650 | def dummy_handler(self,etype,value,tb,tb_offset=None): |
|
1650 | def dummy_handler(self, etype, value, tb, tb_offset=None): | |
1651 | print('*** Simple custom exception handler ***') |
|
1651 | print('*** Simple custom exception handler ***') | |
1652 | print('Exception type :',etype) |
|
1652 | print('Exception type :',etype) | |
1653 | print('Exception value:',value) |
|
1653 | print('Exception value:',value) | |
@@ -2682,6 +2682,10 b' class InteractiveShell(SingletonConfigurable):' | |||||
2682 | # Compile to bytecode |
|
2682 | # Compile to bytecode | |
2683 | try: |
|
2683 | try: | |
2684 | code_ast = compiler.ast_parse(cell, filename=cell_name) |
|
2684 | code_ast = compiler.ast_parse(cell, filename=cell_name) | |
|
2685 | except self.custom_exceptions as e: | |||
|
2686 | etype, value, tb = sys.exc_info() | |||
|
2687 | self.CustomTB(etype, value, tb) | |||
|
2688 | return error_before_exec(e) | |||
2685 | except IndentationError as e: |
|
2689 | except IndentationError as e: | |
2686 | self.showindentationerror() |
|
2690 | self.showindentationerror() | |
2687 | if store_history: |
|
2691 | if store_history: |
General Comments 0
You need to be logged in to leave comments.
Login now