def ensure_unicode(x):
  """Convert `x` to unicode, if it is not unicode already."""
  if isinstance(x, six.text_type):
    return x
  else:
    return six.text_type(str(x), "utf8")
Convert `x` to unicode, if it is not unicode already.
language/boolq/utils/py_utils.py