Comment 4 for bug 323270

Revision history for this message
Ronald Blaschke (rblasch) wrote : Re: [Bug 323270] Re: DeprecationWarning: the md5 module is deprecated; use hashlib instead

Jelmer Vernooij wrote:
> On Fri, 2009-01-30 at 19:00 +0000, Ronald Blaschke wrote:
>> Not exactly sure, but I think hashlib is already available in 2.5, it's
>> just that md5 is deprecated with 2.6. Here's what I did for my 2.6
>> install (the warning is just too annoying.)
> It's not available in python2.4 though, and we need it to work there
> too. Does:
>
> import hashlib
>
> hashlib.md5.new()
>
> work ?

I'm sorry, no.

Traceback (most recent call last):
  File "t.py", line 3, in <module>
    hashlib.md5.new()
AttributeError: 'builtin_function_or_method' object has no attribute 'new'

I've seen two ways to handle the situation for 2.4. Either an explict
version check (e.g. bzrlib/osutils.py) or fallback handling (e.g.
http://hg.stuvel.eu/flickrapi/rev/c96a2d1288ef).

But if you don't use 2.6 please feel free to put the issue aside for
now. I don't mind the local changes I've made. But I hope it's okay if
I report 2.6 issues/warnings still.

Ron