From 5a35d6017850ecf5ab09670074c81a68f1768fc8 Mon Sep 17 00:00:00 2001 From: John Garland Date: Thu, 7 Jan 2010 15:27:05 +0000 Subject: Use cStringIO to open zip files in python 2.5 --- ChangeLog | 1 + deluge/plugins/blocklist/blocklist/decompressers.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2cf45bd83..6ebff21cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ * Minor speedup in parsing blocklists * Blocklist now attempts to download the URL multiple times before giving up + * Fix blocklist not being able to open zipped blocklists with python 2.5 ==== Web ==== * Put the default password in the manpage. 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 -- cgit