

def parse_cookie(header, charset='utf-8', errors='replace', cls=None):
    "Parse a cookie.  Either from a string or WSGI environ.\n\n    Per default encoding errors are ignored.  If you want a different behavior\n    you can set `errors` to ``'replace'`` or ``'strict'``.  In strict mode a\n    :exc:`HTTPUnicodeError` is raised.\n\n    .. versionchanged:: 0.5\n       This function now returns a :class:`TypeConversionDict` instead of a\n       regular dict.  The `cls` parameter was added.\n\n    :param header: the header to be used to parse the cookie.  Alternatively\n                   this can be a WSGI environment.\n    :param charset: the charset for the cookie values.\n    :param errors: the error behavior for the charset decoding.\n    :param cls: an optional dict class to use.  If this is not specified\n                       or `None` the default :class:`TypeConversionDict` is\n                       used.\n    "
    if isinstance(header, dict):
        header = header.get('HTTP_COOKIE', '')
    elif (header is None):
        header = ''
    if isinstance(header, text_type):
        header = charset.encode('latin1', 'replace')
    if (cls is None):
        cls = TypeConversionDict

    def _parse_pairs():
        for (key, val) in _cookie_parse_impl(header):
            key = to_unicode(key, charset, errors, allow_none_charset=True)
            val = to_unicode(val, charset, errors, allow_none_charset=True)
            (yield (try_coerce_native(key), val))
    return cls(_parse_pairs())

dataset/ETHPy150Open Eforcers/gae-flask-todo/lib/werkzeug/http.py parse_cookie/VarMisuse@72/398 `header`->`charset`