def reraise(original, exception):
prev_cls, prev, tb = sys.exc_info()
frames = inspect.getinnerframes(tb)
if len(frames) > 1:
exception = original
try:
raise exception.with_traceback(tb)
except AttributeError:
# This syntax is not a valid Python 3 syntax so we have
# to work around that
exec('raise exception.__class__, exception, tb')
评论列表
文章目录