Commit 9508a471 authored by Michal Čihař's avatar Michal Čihař

Use BytesIO instead of StringIO

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 538eac74
......@@ -137,7 +137,8 @@ def checksum_question(question, timestamp):
'''
Returns checksum for a question.
'''
sha = hashlib.sha1(settings.SECRET_KEY + question + timestamp)
challenge = ''.join((settings.SECRET_KEY, question, timestamp))
sha = hashlib.sha1(challenge.encode('utf-8'))
return sha.hexdigest()
......
......@@ -23,9 +23,9 @@ Tests for translation views.
"""
from xml.dom import minidom
from io import BytesIO
from six.moves.urllib.parse import urlsplit
from six import StringIO
from django.test.client import RequestFactory
from django.contrib.auth.models import Group, User
......@@ -182,7 +182,7 @@ class ViewTestCase(RepoTestCase):
def assertPNGData(self, content):
"""Checks whether data is PNG image"""
# Try to load PNG with PIL
image = Image.open(StringIO(content))
image = Image.open(BytesIO(content))
self.assertEqual(image.format, 'PNG')
def assertSVG(self, response):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment