code: def serialize_unicode(self, data):
          
          try:
              return data.value
          except AttributeError:
              pass
          try:
              if isinstance(data, unicode):
                  return data.encode(encoding='utf-8')
          except NameError:
              return str(data)
          else:
              return str(data)
docs: Special handling for serializing unicode strings in Py2.
          Encode to UTF-8 if unicode, otherwise handle as a str.
  
          :param data: Object to be serialized.
          :rtype: str