Port keystonemiddleware to Python 3
On Python 3, memcache returns data as Unicode, but the hmac module expects bytes. Encode data to UTF-8. Fix also DisableModuleFixture.clear_module() on Python 3. dict.keys() is now an iterator on Python 3: create a list because sys.modules is modified in the loop body. Closes-Bug: #1449423 Change-Id: Id4805c01b0127a3a86235a7d1a4bb3863b51a6b6
This commit is contained in:
parent
1e19e6e64a
commit
83f5d3ab5d
@ -268,6 +268,8 @@ class TokenCache(object):
|
||||
if serialized is None:
|
||||
return None
|
||||
|
||||
if isinstance(serialized, six.text_type):
|
||||
serialized = serialized.encode('utf8')
|
||||
data = self._deserialize(serialized, context)
|
||||
|
||||
# Note that _INVALID_INDICATOR and (data, expires) are the only
|
||||
|
@ -108,7 +108,7 @@ class DisableModuleFixture(fixtures.Fixture):
|
||||
|
||||
def clear_module(self):
|
||||
cleared_modules = {}
|
||||
for fullname in sys.modules.keys():
|
||||
for fullname in list(sys.modules.keys()):
|
||||
if (fullname == self.module or
|
||||
fullname.startswith(self.module + '.')):
|
||||
cleared_modules[fullname] = sys.modules.pop(fullname)
|
||||
|
Loading…
x
Reference in New Issue
Block a user