From 187ec5a1664377337afdc9c701307717ab80ab9e Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 15 Aug 2012 12:37:08 +0200 Subject: [PATCH] [py3] Pass bytes to md5 in truncate_name --- django/db/backends/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django/db/backends/util.py b/django/db/backends/util.py index 775bb3e182..9d70248ebf 100644 --- a/django/db/backends/util.py +++ b/django/db/backends/util.py @@ -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):