Kaydet (Commit) c28281f9 authored tarafından Łukasz Langa's avatar Łukasz Langa

Fixed a Python 2.6 regression (GzipFile can't act as a context manager)

üst b1ac241d
...@@ -11,8 +11,11 @@ from django.test import TestCase ...@@ -11,8 +11,11 @@ from django.test import TestCase
# based on Python 3.3's gzip.compress # based on Python 3.3's gzip.compress
def gzip_compress(data): def gzip_compress(data):
buf = io.BytesIO() buf = io.BytesIO()
with gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=0) as f: f = gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=0)
try:
f.write(data) f.write(data)
finally:
f.close()
return buf.getvalue() return buf.getvalue()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment