[py3] Pass bytes to md5 in truncate_name

This commit is contained in:
Claude Paroz 2012-08-15 12:37:08 +02:00
parent 2d2dca2d8e
commit 187ec5a166
1 changed files with 2 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import hashlib
from time import time
from django.conf import settings
from django.utils.encoding import smart_bytes
from django.utils.log import getLogger
from django.utils.timezone import utc
@ -137,7 +138,7 @@ def truncate_name(name, length=None, hash_len=4):
if length is None or len(name) <= length:
return name
hsh = hashlib.md5(name).hexdigest()[:hash_len]
hsh = hashlib.md5(smart_bytes(name)).hexdigest()[:hash_len]
return '%s%s' % (name[:length-hash_len], hsh)
def format_number(value, max_digits, decimal_places):