osclib/memoize: Fix memoize without session=True
shelf only supports str as key, so convert bytes to str.
This commit is contained in:
parent
a3417b2907
commit
fc92697c3b
@ -118,7 +118,8 @@ def memoize(ttl=None, session=False, add_invalidate=False):
|
|||||||
# representation.
|
# representation.
|
||||||
key = pickle.dumps(obj, protocol=-1)
|
key = pickle.dumps(obj, protocol=-1)
|
||||||
key = pickle.dumps(pickle.loads(key), protocol=-1)
|
key = pickle.dumps(pickle.loads(key), protocol=-1)
|
||||||
return key
|
# shelve only support str keys
|
||||||
|
return key if session else str(key)
|
||||||
|
|
||||||
def _invalidate(*args, **kwargs):
|
def _invalidate(*args, **kwargs):
|
||||||
key = _key((args, kwargs))
|
key = _key((args, kwargs))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user