changeset 11946:851161f07068

util: avoid using hashlib on Python < 2.5 (issue2278) The following patch allows the use of python2.4 with a standalone hashlib rather than assuming that python2.5 is in use when hashlib is imported successfully.
author Sol Jerome <sol.jerome@gmail.com>
date Tue, 17 Aug 2010 17:38:19 -0500
parents 5094e6b2f640
children 59ec12093261
files mercurial/util.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Wed Aug 11 20:28:39 2010 +0800
+++ b/mercurial/util.py	Tue Aug 17 17:38:19 2010 -0500
@@ -28,9 +28,9 @@
     # This function will import sha1 from hashlib or sha (whichever is
     # available) and overwrite itself with it on the first call.
     # Subsequent calls will go directly to the imported function.
-    try:
+    if sys.version_info >= (2, 5):
         from hashlib import sha1 as _sha1
-    except ImportError:
+    else:
         from sha import sha as _sha1
     global _fastsha1, sha1
     _fastsha1 = sha1 = _sha1