def force_text(s, encoding="utf-8"):
    if isinstance(s, six.text_type):
        return s
    try:
        if not isinstance(s, six.string_types):
            if six.PY3:
                if isinstance(s, bytes):
                    s = six.text_type(s, encoding)
                else:
                    s = six.text_type(s)
            elif hasattr(s, '__unicode__'):
                s = six.text_type(s)
            else:
                s = six.text_type(bytes(s), encoding)
        else:
            s = s.decode(encoding)
        return s
    except (__HOLE__, UnicodeEncodeError):
        pass
dataset/ETHPy150Open cobrateam/django-htmlmin/htmlmin/util.py/force_text