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,11 +3,7 @@ import unicodedata
import warnings
from gzip import GzipFile
from htmlentitydefs import name2codepoint
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
from io import BytesIO
from django.utils.encoding import force_unicode
from django.utils.functional import allow_lazy, SimpleLazyObject
@ -277,7 +273,7 @@ phone2numeric = allow_lazy(phone2numeric)
# From http://www.xhaus.com/alan/python/httpcomp.html#gzip
# Used with permission.
def compress_string(s):
zbuf = StringIO()
zbuf = BytesIO()
zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
zfile.write(s)
zfile.close()