details: http://www.bx.psu.edu/hg/galaxy/rev/60308825b252 changeset: 3351:60308825b252 user: Ross Lazarus <ross.lazarus@gmail.com> date: Fri Feb 05 23:03:03 2010 -0500 description: python2.4 sha.new() cannot be based to hmac - this patch tested with 2.4 and 2.5 diffstat: lib/galaxy/util/hash_util.py | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diffs (30 lines): diff -r 4af74d038535 -r 60308825b252 lib/galaxy/util/hash_util.py --- a/lib/galaxy/util/hash_util.py Fri Feb 05 19:35:52 2010 -0500 +++ b/lib/galaxy/util/hash_util.py Fri Feb 05 23:03:03 2010 -0500 @@ -6,15 +6,16 @@ import sys, logging # Use hashlib module if for Python 2.5+, fall back on old sha and md5 modules +# sha1 requires explicit calls to new if also being passed to hmac (!) try: import hashlib sha1 = hashlib.sha1 + sha = sha1 md5 = hashlib.md5 except ImportError, e: - import sha, md5 - sha1 = sha.new - md5 = md5.new - + from sha import new as sha1 + import sha + from md5 import new as md5 import hmac log = logging.getLogger( __name__ ) @@ -30,4 +31,4 @@ return sha1() def hmac_new( key, value ): - return hmac.new( key, value, sha1 ).hexdigest() + return hmac.new( key, value, sha ).hexdigest()