From 8175b2af58986a8e91f417f1758efce119358fee Mon Sep 17 00:00:00 2001 From: John Garland Date: Thu, 7 Jan 2010 15:27:05 +0000 Subject: [PATCH] Use cStringIO to open zip files in python 2.5 --- deluge/plugins/blocklist/blocklist/decompressers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/deluge/plugins/blocklist/blocklist/decompressers.py b/deluge/plugins/blocklist/blocklist/decompressers.py index df3ac0c35..ccc4dfc21 100644 --- a/deluge/plugins/blocklist/blocklist/decompressers.py +++ b/deluge/plugins/blocklist/blocklist/decompressers.py @@ -39,7 +39,13 @@ def Zipped(reader): """Blocklist reader for zipped blocklists""" def open(self): z = zipfile.ZipFile(self.file) - return z.open(z.namelist()[0]) + if hasattr(z, 'open'): + f = z.open(z.namelist()[0]) + else: + # Handle python 2.5 + import cStringIO + f = cStringIO.StringIO(z.read(z.namelist()[0])) + return f reader.open = open return reader