From 0d9d07819774829d887b1d062e007e720c03db9f 2017-05-08 12:18:26 From: Thomas Kluyver Date: 2017-05-08 12:18:26 Subject: [PATCH] Merge pull request #10514 from Carreau/do-not-rely-assert Do not rely on assert to catch errors. --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index cb4924b..7b06565 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -1628,16 +1628,14 @@ class InteractiveShell(SingletonConfigurable): WARNING: by putting in your own exception handler into IPython's main execution loop, you run a very good chance of nasty crashes. This facility should only be used if you really know what you are doing.""" - - assert type(exc_tuple)==type(()) , \ - "The custom exceptions must be given AS A TUPLE." + if not isinstance(exc_tuple, tuple): + raise TypeError("The custom exceptions must be given as a tuple.") def dummy_handler(self, etype, value, tb, tb_offset=None): print('*** Simple custom exception handler ***') - print('Exception type :',etype) - print('Exception value:',value) - print('Traceback :',tb) - #print 'Source code :','\n'.join(self.buffer) + print('Exception type :', etype) + print('Exception value:', value) + print('Traceback :', tb) def validate_stb(stb): """validate structured traceback return type