Author: kmtracey
Date: 2010-05-28 06:46:03 -0500 (Fri, 28 May 2010)
New Revision: 13310

Modified:
   django/trunk/django/utils/hashcompat.py
Log:
Fixed #13653: Fixed django.utils.hashcompat to support running on Python 2.4 
with standalone hashlib.


Modified: django/trunk/django/utils/hashcompat.py
===================================================================
--- django/trunk/django/utils/hashcompat.py     2010-05-28 11:15:36 UTC (rev 
13309)
+++ django/trunk/django/utils/hashcompat.py     2010-05-28 11:46:03 UTC (rev 
13310)
@@ -1,17 +1,17 @@
 """
 The md5 and sha modules are deprecated since Python 2.5, replaced by the
 hashlib module containing both hash algorithms. Here, we provide a common
-interface to the md5 and sha constructors, preferring the hashlib module when
-available.
+interface to the md5 and sha constructors, depending on system version.
 """
 
-try:
+import sys
+if sys.version_info >= (2, 5):
     import hashlib
     md5_constructor = hashlib.md5
     md5_hmac = md5_constructor
     sha_constructor = hashlib.sha1
     sha_hmac = sha_constructor
-except ImportError:
+else:
     import md5
     md5_constructor = md5.new
     md5_hmac = md5

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to