Why is this not working?
try: 1/0 except ZeroDivisionError as e: e.message += ', you fool!' raise
A modified message is not used, even if it remains on the exception instance. Is there a working scheme for the above? The behavior should be similar to my current workaround below:
try: 1/0 except ZeroDivisionError as e: args = e.args if not args: arg0 = '' else: arg0 = args[0] arg0 += ', you fool!' e.args = (arg0,) + args[1:] raise
I know the exception chain in python3, it looks good, but unfortunately does not work in python2. So what is the usual recipe for recreating an exception in python2?
Note. Due to the warnings and cautions mentioned here , I don't want to dig up the trace and create a new exception, but rather raise an existing exception .
source share