]> granicus.if.org Git - python/commitdiff
Have md5 raise a DeprecationWarning as per PEP 4.
authorBrett Cannon <bcannon@gmail.com>
Wed, 30 May 2007 22:24:28 +0000 (22:24 +0000)
committerBrett Cannon <bcannon@gmail.com>
Wed, 30 May 2007 22:24:28 +0000 (22:24 +0000)
Lib/md5.py
Lib/test/test_md5.py
Lib/test/test_pep247.py
Lib/test/test_tarfile.py
Lib/uuid.py
Misc/NEWS

index bbe1984d14ad5f86e6e767b866de6781644f9418..f6433ccbc942ccd1d6fe324d2dcaba3661efa29b 100644 (file)
@@ -3,6 +3,10 @@
 #  Copyright (C) 2005   Gregory P. Smith (greg@electricrain.com)
 #  Licensed to PSF under a Contributor Agreement.
 
+import warnings
+warnings.warn("the md5 module is deprecated; use hashlib instead",
+                DeprecationWarning, 2)
+
 from hashlib import md5
 new = md5
 
index 1f08568508b7e537911fb323c595e3bcc6ea045e..2c0e8e2ca92879463f4cc664946d048b5257b870 100644 (file)
@@ -1,4 +1,7 @@
 # Testing md5 module
+import warnings
+warnings.filterwarnings("ignore", "the md5 module is deprecated.*",
+                        DeprecationWarning)
 
 import unittest
 from md5 import md5
index 88f246131b14fde306321d2d1e034e7102bc5511..1eb94627037e6e2f2f7bc1bd95ceab534405b459 100644 (file)
@@ -3,6 +3,10 @@
 # hashing algorithms.
 #
 
+import warnings
+warnings.filterwarnings("ignore", "the md5 module is deprecated.*",
+                        DeprecationWarning)
+
 import md5, sha, hmac
 
 def check_hash_module(module, key=None):
index 04f9ba5ac84d9422190547f2d34b01a7560781b6..67e52e904fe608f689dd9ffddad7d6d64ea76421 100644 (file)
@@ -5,7 +5,7 @@ import os
 import shutil
 import tempfile
 import StringIO
-import md5
+from hashlib import md5
 import errno
 
 import unittest
@@ -25,7 +25,7 @@ except ImportError:
     bz2 = None
 
 def md5sum(data):
-    return md5.new(data).hexdigest()
+    return md5(data).hexdigest()
 
 def path(path):
     return test_support.findfile(path)
index ae3da25ca55771f9b6d55794b969b6ff9659eab2..eb12d7810a9753ec784a507821ea85e466cfb7e3 100644 (file)
@@ -506,8 +506,8 @@ def uuid1(node=None, clock_seq=None):
 
 def uuid3(namespace, name):
     """Generate a UUID from the MD5 hash of a namespace UUID and a name."""
-    import md5
-    hash = md5.md5(namespace.bytes + name).digest()
+    from hashlib import md5
+    hash = md5(namespace.bytes + name).digest()
     return UUID(bytes=hash[:16], version=3)
 
 def uuid4():
index 8f4bcebb8c4c402535232d2a2e7d44fc1e5c019e..c1f3763b28fcd41a251da7be06630b1dbd9f6e14 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -220,6 +220,8 @@ Core and builtins
 Library
 -------
 
+- md5 now raises a DeprecationWarning upon import.
+
 - mimify now raises a DeprecationWarning upon import.
 
 - MimeWriter now raises a DeprecationWarning upon import.