DeprecationWarning: the md5 module is deprecated

Apache's error_log:
/usr/local/lib/python2.6/site-packages/mod_python/importer.py:32: DeprecationWarning: the md5 module is deprecated; use hashlib instead import md5

Solution:
Found this to be a bug under GOOGLE, Found a solution at Red Hat Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=526062

mod_python patch:

--- mod_python-3.3.1/lib/python/mod_python/importer.py
+++ mod_python-3.3.1/lib/python/mod_python/importer.py
@@ -29,7 +29,10 @@ import new
 import types
 import pdb
 import imp
-import md5
+try:
+    from hashlib import md5
+except ImportError:
+    from md5 import md5
 import time
 import string
 import StringIO
@@ -969,7 +972,7 @@ class _ModuleCache:
         # name which is a filesystem path. Hope MD5 hex
         # digest is okay.
 
-        return self._prefix + md5.new(file).hexdigest()
+        return self._prefix + md5(file).hexdigest()
 
 
 _global_modules_cache = _ModuleCache()

Related Posts