Cannot use with statement with StringIO

This commit is contained in:
Stefano Rivera 2011-01-15 13:55:20 +02:00
parent 394d956a37
commit e48a2c92d4

View File

@ -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