docs: def to_unicode(value, encoding=None):
      """Converts a string argument to a unicode string.
      """
      if isinstance(value, text_type):
          return value
      elif isinstance(value, type(None)):
          return text_type(value)
  
      if not isinstance(value, bytes):
          raise TypeError(
              "Expected bytes, unicode, or None; got %r" % type(value)
          )
  
      if encoding is not None:
          return value.decode(encoding)
      else:
          try:
              value = value.decode('utf-8')
          except:
              try:
                  value = value.decode('gbk')
              except:
                  pass
  
          return value