[py3] Avoided the deprecated base64 interface.
This fixes a deprecation warning under Python 3.
This commit is contained in:
parent
928baee747
commit
212a512984
|
@ -81,10 +81,10 @@ class SessionBase(object):
|
||||||
"Returns the given session dictionary pickled and encoded as a string."
|
"Returns the given session dictionary pickled and encoded as a string."
|
||||||
pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)
|
pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)
|
||||||
hash = self._hash(pickled)
|
hash = self._hash(pickled)
|
||||||
return base64.encodestring(hash.encode() + b":" + pickled)
|
return base64.b64encode(hash.encode() + b":" + pickled)
|
||||||
|
|
||||||
def decode(self, session_data):
|
def decode(self, session_data):
|
||||||
encoded_data = base64.decodestring(smart_bytes(session_data))
|
encoded_data = base64.b64decode(smart_bytes(session_data))
|
||||||
try:
|
try:
|
||||||
# could produce ValueError if there is no ':'
|
# could produce ValueError if there is no ':'
|
||||||
hash, pickled = encoded_data.split(b':', 1)
|
hash, pickled = encoded_data.split(b':', 1)
|
||||||
|
|
|
@ -72,7 +72,7 @@ class DatabaseCache(BaseDatabaseCache):
|
||||||
transaction.commit_unless_managed(using=db)
|
transaction.commit_unless_managed(using=db)
|
||||||
return default
|
return default
|
||||||
value = connections[db].ops.process_clob(row[1])
|
value = connections[db].ops.process_clob(row[1])
|
||||||
return pickle.loads(base64.decodestring(value))
|
return pickle.loads(base64.b64decode(value))
|
||||||
|
|
||||||
def set(self, key, value, timeout=None, version=None):
|
def set(self, key, value, timeout=None, version=None):
|
||||||
key = self.make_key(key, version=version)
|
key = self.make_key(key, version=version)
|
||||||
|
@ -103,7 +103,7 @@ class DatabaseCache(BaseDatabaseCache):
|
||||||
if num > self._max_entries:
|
if num > self._max_entries:
|
||||||
self._cull(db, cursor, now)
|
self._cull(db, cursor, now)
|
||||||
pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
|
pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
|
||||||
encoded = base64.encodestring(pickled).strip()
|
encoded = base64.b64encode(pickled).strip()
|
||||||
cursor.execute("SELECT cache_key, expires FROM %s "
|
cursor.execute("SELECT cache_key, expires FROM %s "
|
||||||
"WHERE cache_key = %%s" % table, [key])
|
"WHERE cache_key = %%s" % table, [key])
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue