import traceback


def format_exception(type, value, tb):
    """Single string return wrapper for traceback.format_exception
    used by nrnpyerr_str
    """

    slist = (
        traceback.format_exception_only(type, value)
        if tb is None
        else traceback.format_exception(type, value, tb)
    )
    s = "".join(slist)
    return s