python2 vs. python3 raise statement python2 vs. python3 raise statement flask flask

python2 vs. python3 raise statement


This is specified in the documentation for the raise statement:

You can create an exception and set your own traceback in one step using the with_traceback() exception method (which returns the same exception instance, with its traceback set to its argument), like so:

raise Exception("foo occurred").with_traceback(tracebackobj)

So, in your case, that would be:

raise exc_type(exc_value).with_traceback(tb)