From: stevenknight Date: Thu, 16 Dec 2004 17:35:43 +0000 (+0000) Subject: Use the builtin md5 hexdigest routine if it's available. (Kevin Quick) X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=8f956678bcda63d397702477fe6910e219e771e2;p=scons.git Use the builtin md5 hexdigest routine if it's available. (Kevin Quick) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1191 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 9f6328f3..55e74ff9 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -332,7 +332,9 @@ RELEASE 0.97 - XXX - Internal cleanups: Remove an unnecessary scan argument. Associate Scanners only with Builders, not nodes. Apply overrides once when a - Builder is called, not in multiple places. + Builder is called, not in multiple places. Cache results from + the Node.FS.get_suffix() and Node.get_build_env() methods. Use + the Python md5 modules' hexdigest() method, if there is one. - Use the correct scanner if the same source file is used for targets in two different environments with the same path but different scanners. diff --git a/src/engine/SCons/Sig/MD5.py b/src/engine/SCons/Sig/MD5.py index 21cb24c0..2adcee09 100644 --- a/src/engine/SCons/Sig/MD5.py +++ b/src/engine/SCons/Sig/MD5.py @@ -58,10 +58,18 @@ def hexdigest(s): h = string.hexdigits r = '' for c in s: - i = ord(c) - r = r + h[(i >> 4) & 0xF] + h[i & 0xF] + i = ord(c) + r = r + h[(i >> 4) & 0xF] + h[i & 0xF] return r +try: + a = md5.new('test').hexdigest() +except AttributeError: + md5sig = lambda c: hexdigest(md5.new(str(c)).digest()) +else: + md5sig = lambda c: md5.new(str(c)).hexdigest() + + def collect(signatures): """ Collect a list of signatures into an aggregate signature. @@ -82,7 +90,7 @@ def signature(obj): gc = obj.get_contents except AttributeError: raise AttributeError, "unable to fetch contents of '%s'" % str(obj) - return hexdigest(md5.new(str(gc())).digest()) + return md5sig(gc()) def to_string(signature): """Convert a signature to a string"""