From 15a7cb8a27d80967894c51a9c3c992e4791f7643 Mon Sep 17 00:00:00 2001
From: Bastian Kleineidam <calvin@debian.org>
Date: Mon, 28 Jan 2008 10:52:58 +0100
Subject: Close open file descriptors
Close another file descriptor leak.
Signed-off-by: Bastian Kleineidam <calvin@debian.org>
diff --git a/django/utils/text.py b/django/utils/text.py
index 4670ab4..1c78f99 100644
a
|
b
|
|
1 | 1 | import re |
| 2 | import gzip |
| 3 | from cStringIO import StringIO |
2 | 4 | from django.conf import settings |
3 | 5 | from django.utils.encoding import force_unicode |
4 | 6 | from django.utils.functional import allow_lazy |
… |
… |
phone2numeric = allow_lazy(phone2numeric)
|
168 | 170 | # From http://www.xhaus.com/alan/python/httpcomp.html#gzip |
169 | 171 | # Used with permission. |
170 | 172 | def compress_string(s): |
171 | | import cStringIO, gzip |
172 | | zbuf = cStringIO.StringIO() |
| 173 | zbuf = StringIO() |
173 | 174 | zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf) |
174 | | zfile.write(s) |
175 | | zfile.close() |
| 175 | try: |
| 176 | zfile.write(s) |
| 177 | finally: |
| 178 | zfile.close() |
176 | 179 | return zbuf.getvalue() |
177 | 180 | |
178 | 181 | ustring_re = re.compile(u"([\u0080-\uffff])") |