Browse Source

fix py3.5k errors

Rafał Pitoń 8 years ago
parent
commit
bbea86a86c

+ 5 - 4
misago/threads/models/attachment.py

@@ -1,11 +1,9 @@
-from io import BytesIO
-
 from django.conf import settings
 from django.core.files import File
 from django.core.files.base import ContentFile
 from django.core.urlresolvers import reverse
 from django.db import models
-from django.utils import timezone
+from django.utils import six, timezone
 from django.utils.crypto import get_random_string
 from PIL import Image
 
@@ -81,7 +79,10 @@ class Attachment(models.Model):
         thumbnail = Image.open(upload)
         thumbnail.thumbnail((500, 500))
 
-        thumb_stream = BytesIO()
+        if six.PY3:
+            thumb_stream = six.StringIO()
+        else:
+            thumb_stream = six.BytesIO()
         thumbnail.save(thumb_stream, fileformat)
 
         thumb_secret = get_random_string(settings.MISAGO_ATTACHMENT_SECRET_LENGTH)

+ 1 - 1
misago/threads/tests/test_attachmenttypeadmin_views.py

@@ -131,7 +131,7 @@ class AttachmentTypeAdminViewsTests(AdminTestCase):
             self.assertEqual(response.status_code, 302)
 
             test_type = AttachmentType.objects.order_by('id').last()
-            self.assertEqual(test_type.extensions_list, final)
+            self.assertEqual(set(test_type.extensions_list), set(final))
 
     def test_delete_view(self):
         """delete attachment type view has no showstoppers"""