Commits

Anonymous committed f436f0c

Fixed five errors as described here: http://bitbucket.org/fiji/django-3k/issue/91/

from FAILED (failures=331, errors=153)
to FAILED (failures=331, errors=148)

  • Participants
  • Parent commits 01958a5

Comments (0)

Files changed (2)

django/core/files/base.py

 
 from django.utils.encoding import smart_str, smart_unicode
 from django.core.files.utils import FileProxyMixin
+from django.utils.py3 import to_utf8_bytes
 
 class File(FileProxyMixin):
     DEFAULT_CHUNK_SIZE = 64 * 2**10
     """
     def __init__(self, content):
         content = content or ''
-        super(ContentFile, self).__init__(StringIO(content))
+        super(ContentFile, self).__init__(StringIO(to_utf8_bytes(content)))
         self.size = len(content)
 
     def __str__(self):

django/utils/py3.py

 def to_utf8_string(s): 
     # Convert byte s, if any, to str 
     if not isinstance(s, str) and sys.version_info >= (3,): 
-        return str(s, encoding='utf8')
+        return str(s, encoding='utf8')
+
+def to_utf8_bytes(s): 
+    # Convert string s to bytes
+    if isinstance(s, str) and sys.version_info >= (3,): 
+        return bytes(s, encoding='utf8')