From e48a2c92d4aea26bc7ba1797f70abbca59369f68 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sat, 15 Jan 2011 13:55:20 +0200 Subject: [PATCH] Cannot use with statement with StringIO --- ubuntutools/archive.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py index 2907f28..ee43262 100644 --- a/ubuntutools/archive.py +++ b/ubuntutools/archive.py @@ -76,12 +76,13 @@ class Dsc(debian.deb822.Dsc): if os.path.getsize(pathname) != size: return False hash_func = getattr(hashlib, alg)() - with open(pathname, 'rb') as f: - while True: - buf = f.read(hash_func.block_size) - if buf == '': - break - hash_func.update(buf) + f = open(pathname, 'rb') + while True: + buf = f.read(hash_func.block_size) + if buf == '': + break + hash_func.update(buf) + f.close() return hash_func.hexdigest() == digest return False