zlorf/django-dbsettings

hashlib.md5 problems in Python 3.5 with ImageValue

Closed this issue · 1 comments

Hello,

The fix applied for Issue #28 is raising a new error on Python 3.5:

hashed_name = md5(six.binary_type(time.time())).hexdigest() + value.name[-4:]
TypeError: 'float' object is not iterable

Current Line 309:

        hashed_name = md5(six.binary_type(time.time())).hexdigest() + value.name[-4:]

SOLUTION

Please go back using function six.text_type() and encode the result so it is compatible with Python 3.0+.

Line 309 must be like this:

        hashed_name = md5(six.text_type(time.time()).encode()).hexdigest() + value.name[-4:]

It was tested on Python 2.7 and Python 3.5 and works great!

Regards.

zlorf commented

You were right from the start. I didn't like the text_type [...] encode() part, but it seems to be the only way.