From: schlatterbeck Date: Sat, 16 Apr 2011 18:38:18 +0000 (+0000) Subject: python2.4 compatibility fix X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=836ea76d57a4ec4fc9d359dbb9553068bac8c2a6;p=roundup.git python2.4 compatibility fix git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4600 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/anypy/hashlib_.py b/roundup/anypy/hashlib_.py index 9365b97..779176f 100644 --- a/roundup/anypy/hashlib_.py +++ b/roundup/anypy/hashlib_.py @@ -4,8 +4,10 @@ anypy.hashlib_: encapsulation of hashlib/md5/sha1/sha try: from hashlib import md5, sha1 # new in Python 2.5 + shamodule = sha1 except ImportError: from md5 import md5 # deprecated in Python 2.6 from sha import sha as sha1 # deprecated in Python 2.6 + import sha as shamodule # vim: ts=8 sts=4 sw=4 si diff --git a/roundup/password.py b/roundup/password.py index eab3007..006c591 100644 --- a/roundup/password.py +++ b/roundup/password.py @@ -23,7 +23,7 @@ __docformat__ = 'restructuredtext' import re, string, random from base64 import b64encode, b64decode -from roundup.anypy.hashlib_ import md5, sha1 +from roundup.anypy.hashlib_ import md5, sha1, shamodule try: import crypt except ImportError: @@ -59,10 +59,6 @@ except ImportError: #no m2crypto - make our own pbkdf2 function from struct import pack from hmac import HMAC - try: - from hashlib import sha1 - except ImportError: - from sha import new as sha1 def xor_bytes(left, right): "perform bitwise-xor of two byte-strings" @@ -71,7 +67,7 @@ except ImportError: def _pbkdf2(password, salt, rounds, keylen): digest_size = 20 # sha1 generates 20-byte blocks total_blocks = int((keylen+digest_size-1)/digest_size) - hmac_template = HMAC(password, None, sha1) + hmac_template = HMAC(password, None, shamodule) out = _bempty for i in xrange(1, total_blocks+1): hmac = hmac_template.copy()