Refs #27795 -- Replaced force_bytes() usage in django.core.cache.

This commit is contained in:
Jon Dufresne 2018-02-01 23:57:58 -08:00 committed by Carlton Gibson
parent 75e45a45e7
commit 6a039800db
3 changed files with 3 additions and 7 deletions

View File

@ -7,7 +7,6 @@ from django.conf import settings
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.db import DatabaseError, connections, models, router, transaction
from django.utils import timezone
from django.utils.encoding import force_bytes
from django.utils.inspect import func_supports_parameter
@ -79,7 +78,7 @@ class DatabaseCache(BaseDatabaseCache):
return default
value = connection.ops.process_clob(row[1])
return pickle.loads(base64.b64decode(force_bytes(value)))
return pickle.loads(base64.b64decode(value.encode()))
def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
key = self.make_key(key, version=version)

View File

@ -10,7 +10,6 @@ import zlib
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.core.files.move import file_move_safe
from django.utils.encoding import force_bytes
class FileBasedCache(BaseCache):
@ -106,7 +105,7 @@ class FileBasedCache(BaseCache):
key = self.make_key(key, version=version)
self.validate_key(key)
return os.path.join(self._dir, ''.join(
[hashlib.md5(force_bytes(key)).hexdigest(), self.cache_suffix]))
[hashlib.md5(key.encode()).hexdigest(), self.cache_suffix]))
def clear(self):
"""

View File

@ -1,8 +1,6 @@
import hashlib
from urllib.parse import quote
from django.utils.encoding import force_bytes
TEMPLATE_FRAGMENT_KEY_TEMPLATE = 'template.cache.%s.%s'
@ -10,5 +8,5 @@ def make_template_fragment_key(fragment_name, vary_on=None):
if vary_on is None:
vary_on = ()
key = ':'.join(quote(str(var)) for var in vary_on)
args = hashlib.md5(force_bytes(key))
args = hashlib.md5(key.encode())
return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())