1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Replaced cStringIO.StringIO by io.BytesIO.

Also replaced StringIO.StringIO by BytesIO in some other appropriate
places. StringIO is not available in Python 3.
This commit is contained in:
Claude Paroz
2012-05-05 19:47:03 +02:00
parent 1583d40224
commit d7dfab59ea
26 changed files with 94 additions and 167 deletions

View File

@@ -3,10 +3,7 @@ Classes representing uploaded files.
"""
import os
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
from io import BytesIO
from django.conf import settings
from django.core.files.base import File
@@ -110,8 +107,8 @@ class SimpleUploadedFile(InMemoryUploadedFile):
A simple representation of a file, which just has content, size, and a name.
"""
def __init__(self, name, content, content_type='text/plain'):
content = content or ''
super(SimpleUploadedFile, self).__init__(StringIO(content), None, name,
content = content or b''
super(SimpleUploadedFile, self).__init__(BytesIO(content), None, name,
content_type, len(content), None)
def from_dict(cls, file_dict):