From 31f95b77ee6c49c2facb2508a3c28d216f53c62a Mon Sep 17 00:00:00 2001 From: zooko <zooko@zooko.com> Date: Tue, 16 Jun 2009 03:49:23 +0530 Subject: [PATCH] silence deprecation warning by using hashlib if it is present (which it is on Python >= 2.5.0) Ignore-this: 8c1c031028640cf022e4efb2ff9b6e12 darcs-hash:c65550b3ff75901d39e274e7001417aa29790649 --- zfec/zfec/filefec.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zfec/zfec/filefec.py b/zfec/zfec/filefec.py index a6c0a35..99de3bd 100644 --- a/zfec/zfec/filefec.py +++ b/zfec/zfec/filefec.py @@ -347,7 +347,12 @@ def encode_file(inf, cb, k, m, chunksize=4096): res = enc.encode(l) cb(res, indatasize) -import sha +try: + from hashlib import sha1 +except ImportError: + # hashlib was added in Python 2.5.0. + import sha as sha1 + def encode_file_not_really(inf, cb, k, m, chunksize=4096): enc = zfec.Encoder(k, m) l = tuple([ array.array('c') for i in range(k) ]) @@ -380,7 +385,7 @@ def encode_file_not_really(inf, cb, k, m, chunksize=4096): cb(None, None) def encode_file_not_really_and_hash(inf, cb, k, m, chunksize=4096): - hasher = sha.new() + hasher = sha1.new() enc = zfec.Encoder(k, m) l = tuple([ array.array('c') for i in range(k) ]) indatasize = k*chunksize # will be reset to shorter upon EOF -- 2.45.2