import six


def _FmtString(fmt):
  """Gets the correct format string to use based on the Python version.

  Args:
    fmt: text string, The format string to convert.

  Returns:
    A byte string on Python 2 or the original string on Python 3.
  """
  # On Py2, log messages come in as both text and byte strings so the format
  # strings needs to be bytes so it doesn't coerce byte messages to unicode.
  # On Py3, only text strings come in and if the format is bytes it can't
  # combine with the log message.
  if six.PY2:
    return fmt.encode('utf8')
  return fmt