Fix Python 2.6 deprecation warning with the md5 import. Use hashlib instead.

This commit is contained in:
Rob Crittenden 2009-09-16 13:01:28 -04:00 committed by Jason Gerard DeRose
parent 944371a38c
commit 30f9f77727

View File

@ -529,8 +529,11 @@ def uuid1(node=None, clock_seq=None):
def uuid3(namespace, name): def uuid3(namespace, name):
"""Generate a UUID from the MD5 hash of a namespace UUID and a name.""" """Generate a UUID from the MD5 hash of a namespace UUID and a name."""
import md5 try:
hash = md5.md5(namespace.bytes + name).digest() from hashlib import md5
except ImportError:
from md5 import md5
hash = md5(namespace.bytes + name).digest()
return UUID(bytes=hash[:16], version=3) return UUID(bytes=hash[:16], version=3)
def uuid4(): def uuid4():