import traceback


def _formatException(_, ei):
    """
    Format and return the specified exception information as a string.
    This implementation builds the complete stack trace, combining
    traceback.format_exception and traceback.format_stack.
    """
    lines = traceback.format_exception(*ei)
    if ei[2]:
        lines[1:1] = traceback.format_stack(ei[2].tb_frame.f_back)
    return ''.join(lines)