def traceback_str(exc):
    """Call this to get the traceback string associated with the given exception
    or tuple of the form (exc_class, exc, traceback).
    Returns the exception string if there is no traceback.
    """
    if isinstance(exc, tuple) and len(exc) == 3:
        s = StringIO()
        print_exception(*exc, file=s)
        return s.getvalue().strip()

    try:
        return exc.traceback
    except __HOLE__:
        return str(exc)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/exceptions.py/traceback_str