[Fwd: [PATCH] Use hashlib if available instead of md5]

Toshio Kuratomi a.badger at gmail.com
Mon Feb 2 22:47:42 UTC 2009


Jeremy Katz wrote:
> On Monday, February 02 2009, Jesse Keating said:
>> This patch converts all calls of md5 function to use hashlib if present.
>> The old md5 function is deprecated in Python 2.6, and this silences the
>> warning messages (along with providing a slight performance improvement).
> 
> Rather than scattering lazy imports in a try except all over the koji
> code, I wonder if it's worth adding a wrapper in koji.util and only
> doing the try/except once at the module level there.  Probably not
> speed-critical code, but it would also keep things a little more
> readable
> 

Something like:

[util.py]
try:
    from hashlib import md5 as md5_constructor
except ImportError:
    from md5 import new as md5_constructor

[other.py]
from koji.util import md5_constructor

digest = md5_constructor(contents).hexdigest()

-Toshio

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/fedora-buildsys-list/attachments/20090202/62877f22/attachment.sig>


More information about the Fedora-buildsys-list mailing list