Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Always pass bytes to hashlib.md5.

  • Loading branch information...
commit ebc1325721e43808cef4334edaffc23a43f86614 1 parent 52c351a
@apollo13 apollo13 authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 django/templatetags/cache.py
View
6 django/templatetags/cache.py
@@ -4,6 +4,7 @@
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 @@ def render(self, context):
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:
Please sign in to comment.
Something went wrong with that request. Please try again.