From c28281f9d60b12e29481214348abc6084c31d77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Tue, 21 May 2013 13:18:53 +0200 Subject: [PATCH] Fixed a Python 2.6 regression (GzipFile can't act as a context manager) --- tests/http_utils/tests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/http_utils/tests.py b/tests/http_utils/tests.py index 06a310a787..9f99c94da7 100644 --- a/tests/http_utils/tests.py +++ b/tests/http_utils/tests.py @@ -11,8 +11,11 @@ from django.test import TestCase # based on Python 3.3's gzip.compress def gzip_compress(data): 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) + finally: + f.close() return buf.getvalue()