[Checkins] SVN: zc.buildout/branches/help-api/ - Conditionally import and use hashlib.md5 when it's available instead

Godefroid Chapelle gotcha at bubblenet.be
Sun Mar 29 17:26:04 EDT 2009


Log message for revision 98547:
  - Conditionally import and use hashlib.md5 when it's available instead
    of md5 module, which is deprecated in Python 2.6.

Changed:
  U   zc.buildout/branches/help-api/CHANGES.txt
  U   zc.buildout/branches/help-api/src/zc/buildout/buildout.py

-=-
Modified: zc.buildout/branches/help-api/CHANGES.txt
===================================================================
--- zc.buildout/branches/help-api/CHANGES.txt	2009-03-29 21:25:57 UTC (rev 98546)
+++ zc.buildout/branches/help-api/CHANGES.txt	2009-03-29 21:26:04 UTC (rev 98547)
@@ -7,6 +7,9 @@
 1.1.2 (Unreleased)
 ==================
 
+- Conditionally import and use hashlib.md5 when it's available instead
+  of md5 module, which is deprecated in Python 2.6.
+
 - Added Jython support for bootstrap, development bootstrap
   and zc.buildout support on Jython
 

Modified: zc.buildout/branches/help-api/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/buildout.py	2009-03-29 21:25:57 UTC (rev 98546)
+++ zc.buildout/branches/help-api/src/zc/buildout/buildout.py	2009-03-29 21:26:04 UTC (rev 98547)
@@ -18,7 +18,6 @@
 
 import distutils.errors
 import logging
-import md5
 import os
 import re
 import shutil
@@ -34,6 +33,12 @@
 
 from rmtree import rmtree
 
+try:
+    from hashlib import md5
+except ImportError:
+    # Python 2.4 and older
+    from md5 import md5
+
 realpath = zc.buildout.easy_install.realpath
 
 pkg_resources_loc = pkg_resources.working_set.find(
@@ -1289,7 +1294,7 @@
 
 ignore_directories = '.svn', 'CVS'
 def _dir_hash(dir):
-    hash = md5.new()
+    hash = md5()
     for (dirpath, dirnames, filenames) in os.walk(dir):
         dirnames[:] = [n for n in dirnames if n not in ignore_directories]
         filenames[:] = [f for f in filenames



More information about the Checkins mailing list