from io import StringIO
import traceback


def _get_traceback_text(exc_type, value, tb) -> str:
  """return the text that would be printed by
  traceback.print_exception.
  """

  sio = StringIO()
  traceback.print_exception(exc_type, value, tb, file=sio)
  return sio.getvalue()