[Checkins] SVN: grokproject/trunk/ For Python 2.5 and 2.6, use hashlib module instead of the deprecated

Vincent Fretin vincent.fretin at gmail.com
Sun Feb 14 11:44:27 EST 2010


Log message for revision 109051:
  For Python 2.5 and 2.6, use hashlib module instead of the deprecated
  sha module in Python 2.6.
  

Changed:
  U   grokproject/trunk/CHANGES.txt
  U   grokproject/trunk/grokproject/utils.py

-=-
Modified: grokproject/trunk/CHANGES.txt
===================================================================
--- grokproject/trunk/CHANGES.txt	2010-02-14 15:12:09 UTC (rev 109050)
+++ grokproject/trunk/CHANGES.txt	2010-02-14 16:44:26 UTC (rev 109051)
@@ -4,6 +4,9 @@
 1.0.3 (unreleased)
 ------------------
 
+* For Python 2.5 and 2.6, use hashlib module instead of the deprecated
+  sha module in Python 2.6.
+
 * Use bugfixed grokui.admin 0.4.1.
 
 1.0.2 (2010-02-14)

Modified: grokproject/trunk/grokproject/utils.py
===================================================================
--- grokproject/trunk/grokproject/utils.py	2010-02-14 15:12:09 UTC (rev 109050)
+++ grokproject/trunk/grokproject/utils.py	2010-02-14 16:44:26 UTC (rev 109051)
@@ -1,7 +1,6 @@
 import codecs
 import os
 import sys
-import sha
 import shutil
 import tempfile
 import pkg_resources
@@ -9,6 +8,11 @@
 from random import randint
 from paste.script.templates import var
 
+try:
+    from hashlib import sha1
+except ImportError:
+    from sha import sha as sha1
+
 HOME = os.path.expanduser('~')
 
 
@@ -60,7 +64,7 @@
     salt = "%08x" % randint(0, 0xffffffff)
     # This is apparently a wrong use of salt, but the old SHA1
     # password manager of `zope.app.authentication` handles it this way.
-    result = salt + sha.new(encoder(passwd)[0]).hexdigest()
+    result = salt + sha1(encoder(passwd)[0]).hexdigest()
     return result
 
 def get_boolean_value_for_option(vars, option):



More information about the checkins mailing list