Do we know about this deprecation warning for the md5 module in waf?

Richard Sharpe realrichardsharpe at gmail.com
Thu Oct 30 17:20:10 MDT 2014


On Thu, Oct 30, 2014 at 3:59 PM, Richard Sharpe
<realrichardsharpe at gmail.com> wrote:
> On Thu, Oct 30, 2014 at 3:54 PM, Michael Adam <obnox at samba.org> wrote:
>> On 2014-10-30 at 15:49 -0700, Richard Sharpe wrote:
>>> Hi folks,
>>>
>>> I see this when building 4.1.12:
>>>
>>> ./buildtools/wafsamba/samba_utils.py:397: DeprecationWarning: the md5
>>> module is deprecated; use hashlib instead
>>>
>>> Should I prepare a patch or has this been fixed already upstream or whatever?
>>
>> For "buildtools/wafsamba", upstream is us. :-)
>> (waf upstream is in "buildtools/wafadmin")
>>
>> But the warning already comes from the fallback code
>> when the hashlib is not available or does not work as desired.
>> So what patch do you want to prepare?
>
> Hmmm, so maybe my build platform does not have the right stuff on it.
> Time to investigate.

OK, so it turns out that the following code works on my platform: CentOS 6.4:

-------
try:
    from hashlib import md5
    # Even if hashlib.md5 exists, it may be unusable.
    # Try to use MD5 function. In FIPS mode this will cause an exception
    # and we'll get to the replacement code
    foo = md5.md5('abcd')
except:
    import hashlib
    # repeat the same check here, mere success of import is not enough.
    # Try to use MD5 function. In FIPS mode this will cause an exception
    md5 = hashlib
    foo = md5.md5('abcd')

print 'hello'
print foo
------

So, we could squash the deprecation warning with that trick if it was
of interest.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)


More information about the samba-technical mailing list