def Validate(self, value, **_):
    # We only accept a base string, unicode object or RDFString here.
    if not (value.__class__ is str or value.__class__ is unicode or
            value.__class__ is rdfvalue.RDFString):
      raise type_info.TypeValueError("%s not a valid string" % value)

    if value.__class__ is unicode:
      return value

    # A String means a unicode String. We must be dealing with unicode strings
    # here and the input must be encodable as a unicode object.
    try:
      try:
        return value.__unicode__()
      except AttributeError:
        return unicode(value, "utf8")
    except UnicodeError:
      raise type_info.TypeValueError("Not a valid unicode string")
Evaluate to a string in the given globals/locals.
dataset/ETHPy150Open google/grr/grr/lib/rdfvalues/structs.py/ProtoString.Validate--crossover with--dataset/ETHPy150Open ipython/ipython-py3k/IPython/external/Itpl/_Itpl.py/Itpl._str