My Dinky Note

Aditya Arie Nugraha's weblog

md5 Module Problem on mod_python

with one comment

I got this error message in my /var/log/apache2/error.log:

[Fri Aug 14 10:16:51 2009] [error] /usr/lib/python2.6/dist-packages/mod_python/importer.py:32: DeprecationWarning: the md5 module is deprecated; use hashlib instead
[Fri Aug 14 10:16:51 2009] [error]   import md5

I had tried upgrade the libapache2-mod-python package from 3.3.1-6build2 (jaunty package) to 3.3.1-7 (karmic package), but it wasn’t solve the problem.

So, the solution is edit /usr/lib/python2.6/dist-packages/mod_python/importer.py. Change import md5 to from hashlib import md5 and also md5.new(file).hexdigest() to md5(file).hexdigest().

Written by arie

August 14, 2009 at 10:44 am

Posted in Hobbies & Interests

Tagged with , ,

One Response

Subscribe to comments with RSS.

  1. This is only a “DeprecationWarning”. Yes, it means that this module will disappear in the future, but, as it’s a widely used one, I probably won’t happen too soon. On the other hand, the mod_python developers are certainly aware about this deprecation and will issue a fix as necessary.

    I personally do not like to fiddle in code that was installed through a distribution package (as most likely with the case of mod_python).

    An alternative solution would be to create a new module called “md5″ and make sure it’s in the search path /before/ the “original” md5 package. Then make this wrap “hashlib”. Be sure to forward any unknown method calls to the old md5 package and you should be good to go.

    However, this seems badly hackish and will likely break other apps. So, as I stated in the beginning, you should be fine by simply ignoring the warning. In general, package maintainers will be aware that there will be a problem in the future and it’s their job to keep the packages un-broken.

    mod_python is too important for too many people. It won’t break if you keep to the distribution packages. If you hand-compiled packages and did some manual dependency resolution then there may be trouble up ahead. The chance is still small though.

    In summary: I would advise /against/ changing code in /usr/lib/python2.6/dist-packages/mod_python/importer.py

    exhuma

    August 14, 2009 at 6:58 pm


Leave a Reply