瀏覽代碼

Used io.BytesIO also for ContentFile.

io.StringIO would force the content to be Unicode, which would be
slightly backwards incompatible.
Claude Paroz 13 年之前
父節點
當前提交
57102ce781
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      django/core/files/base.py

+ 2 - 2
django/core/files/base.py

@@ -1,5 +1,5 @@
 import os
-from io import BytesIO, StringIO
+from io import BytesIO
 
 from django.utils.encoding import smart_str, smart_unicode
 from django.core.files.utils import FileProxyMixin
@@ -126,7 +126,7 @@ class ContentFile(File):
     """
     def __init__(self, content, name=None):
         content = content or ''
-        super(ContentFile, self).__init__(StringIO(content), name=name)
+        super(ContentFile, self).__init__(BytesIO(content), name=name)
         self.size = len(content)
 
     def __str__(self):