def f(): try: raise ValueError('hello') except ValueError: f() from traceback import print_exception import sys try: f() except Exception as e: exc_info = sys.exc_info() print_exception(exc_info[0], exc_info[1], exc_info[2], None) print('got to the finish line!')