diff options
| author | Florian Apolloner <florian@apolloner.eu> | 2012-08-15 11:31:23 +0200 |
|---|---|---|
| committer | Florian Apolloner <florian@apolloner.eu> | 2012-08-15 11:34:41 +0200 |
| commit | ebc1325721e43808cef4334edaffc23a43f86614 (patch) | |
| tree | 1106900af710e9b14a16d93b32fc1f2426ca885f | |
| parent | 52c351a151b7c7808d652581e97b40da7d700492 (diff) | |
[py3] Always pass bytes to hashlib.md5.
| -rw-r--r-- | django/templatetags/cache.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/django/templatetags/cache.py b/django/templatetags/cache.py index 056eadc7de..e431f99d0d 100644 --- a/django/templatetags/cache.py +++ b/django/templatetags/cache.py @@ -4,6 +4,7 @@ import hashlib from django.template import Library, Node, TemplateSyntaxError, Variable, VariableDoesNotExist from django.template import resolve_variable from django.core.cache import cache +from django.utils.encoding import smart_bytes from django.utils.http import urlquote register = Library() @@ -24,8 +25,9 @@ class CacheNode(Node): expire_time = int(expire_time) except (ValueError, TypeError): raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time) - # Build a unicode key for this fragment and all vary-on's. - args = hashlib.md5(':'.join([urlquote(resolve_variable(var, context)) for var in self.vary_on])) + # Build a key for this fragment and all vary-on's. + key = smart_bytes(':'.join([urlquote(resolve_variable(var, context)) for var in self.vary_on])) + args = hashlib.md5(key) cache_key = 'template.cache.%s.%s' % (self.fragment_name, args.hexdigest()) value = cache.get(cache_key) if value is None: |
