Import hashlib instead of md5/sha when possible
|Reported by:||Owned by:||Karen Tracey|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Running under Python 2.6 (beta2) we get DeprecationWarnings wherever we import md5 or sha, with the recommendation to use hashlib instead. I can work on a patch to get rid of these if I can get some input on the correct way to fix it. Looking at the uses I see so far (haven't quite checked them all yet), it seems that something like:
try: import hashlib md5_constructor = hashlib.md5 except ImportError: import md5 md5_constructor = md5.new
to replace "import md5", plus of course updating the calls to md5.new() or md5.md5() to use md5_constructor() would work. (Plus of course the same technique for where we import sha.) But I don't know if that's the most elegant/practical/desirable way to handle stuff like this, so guidance would be appreciated.