1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

[py3] Encoded value before feeding it to hashlib.md5

This commit is contained in:
Claude Paroz
2012-08-12 22:22:56 +02:00
parent 99321e30ce
commit ac37c9e495
2 changed files with 5 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ except ImportError:
import pickle
from django.core.cache.backends.base import BaseCache
from django.utils.encoding import smart_bytes
class FileBasedCache(BaseCache):
def __init__(self, dir, params):
@@ -136,7 +137,7 @@ class FileBasedCache(BaseCache):
Thus, a cache key of "foo" gets turnned into a file named
``{cache-dir}ac/bd/18db4cc2f85cedef654fccc4a4d8``.
"""
path = hashlib.md5(key).hexdigest()
path = hashlib.md5(smart_bytes(key)).hexdigest()
path = os.path.join(path[:2], path[2:4], path[4:])
return os.path.join(self._dir, path)