Fixing python3
This commit is contained in:
Awais Qureshi
2019-09-20 15:03:02 +05:00
parent c6edb954d5
commit fbd94fc289

View File

@@ -3,6 +3,7 @@ Image file manipulation functions related to profile images.
"""
from __future__ import absolute_import
import binascii
from collections import namedtuple
from contextlib import closing
from io import BytesIO
@@ -128,7 +129,7 @@ def validate_uploaded_image(uploaded_file):
# check magic number matches expected file type
headers = IMAGE_TYPES[filetype].magic
if uploaded_file.read(len(headers[0]) / 2).encode('hex') not in headers:
if binascii.hexlify(uploaded_file.read(len(headers[0]) // 2)).decode('utf-8') not in headers:
file_upload_bad_ext = _(
u'The file name extension for this file does not match '
u'the file data. The file may be corrupted.'