Skip to content
Myr

Fix .iteritems() access in flask.sessions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daniel Neuhäuser · committed by Daniel Neuhäuser · parent d395d36 · Browse files · 1 file+5 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−5 removed

  • other:+5 added−5 removed

1 file+5 added−5 removed

modified:flask/sessions.py+5 added-5 removed
13 unmodified lines
14from datetime import datetime15from werkzeug.http import http_date, parse_date16from werkzeug.datastructures import CallbackDict17from . import Markup, json18from ._compat import iteritems, text_type1920from itsdangerous import URLSafeTimedSerializer, BadSignature20import six212223def total_seconds(td):24 return td.days * 60 * 60 * 24 + td.seconds
37 unmodified lines
62 return {' t': [_tag(x) for x in value]}63 elif isinstance(value, uuid.UUID):64 return {' u': value.hex}65 elif callable(getattr(value, '__html__', None)):66 return {' m': six.text_type(value.__html__())}66 return {' m': text_type(value.__html__())}67 elif isinstance(value, list):68 return [_tag(x) for x in value]69 elif isinstance(value, datetime):70 return {' d': http_date(value)}71 elif isinstance(value, dict):72 return dict((k, _tag(v)) for k, v in six.iteritems(value))72 return dict((k, _tag(v)) for k, v in iteritems(value))73 elif isinstance(value, str):74 try:75 return six.text_type(value)75 return text_type(value)76 except UnicodeError:77 raise UnexpectedUnicodeError(u'A byte string with '78 u'non-ASCII data was passed to the session system '79 u'which can only store unicode strings. Consider '
4 unmodified lines
84 def loads(self, value):85 def object_hook(obj):86 if len(obj) != 1:87 return obj88 the_key, the_value = six.advance_iterator(obj.iteritems())88 the_key, the_value = next(iteritems(obj))89 if the_key == ' t':90 return tuple(the_value)91 elif the_key == ' u':92 return uuid.UUID(the_value)
235 unmodified lines