[Python-checkins] r55696 - in python/trunk: Lib/md5.py Lib/test/test_md5.py Lib/test/test_pep247.py Lib/test/test_tarfile.py Lib/uuid.py Misc/NEWS

brett.cannon python-checkins at python.org
Thu May 31 00:24:38 CEST 2007


Author: brett.cannon
Date: Thu May 31 00:24:28 2007
New Revision: 55696

Modified:
   python/trunk/Lib/md5.py
   python/trunk/Lib/test/test_md5.py
   python/trunk/Lib/test/test_pep247.py
   python/trunk/Lib/test/test_tarfile.py
   python/trunk/Lib/uuid.py
   python/trunk/Misc/NEWS
Log:
Have md5 raise a DeprecationWarning as per PEP 4.


Modified: python/trunk/Lib/md5.py
==============================================================================
--- python/trunk/Lib/md5.py	(original)
+++ python/trunk/Lib/md5.py	Thu May 31 00:24:28 2007
@@ -3,6 +3,10 @@
 #  Copyright (C) 2005   Gregory P. Smith (greg at 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
 

Modified: python/trunk/Lib/test/test_md5.py
==============================================================================
--- python/trunk/Lib/test/test_md5.py	(original)
+++ python/trunk/Lib/test/test_md5.py	Thu May 31 00:24:28 2007
@@ -1,4 +1,7 @@
 # Testing md5 module
+import warnings
+warnings.filterwarnings("ignore", "the md5 module is deprecated.*",
+                        DeprecationWarning)
 
 import unittest
 from md5 import md5

Modified: python/trunk/Lib/test/test_pep247.py
==============================================================================
--- python/trunk/Lib/test/test_pep247.py	(original)
+++ python/trunk/Lib/test/test_pep247.py	Thu May 31 00:24:28 2007
@@ -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):

Modified: python/trunk/Lib/test/test_tarfile.py
==============================================================================
--- python/trunk/Lib/test/test_tarfile.py	(original)
+++ python/trunk/Lib/test/test_tarfile.py	Thu May 31 00:24:28 2007
@@ -5,7 +5,7 @@
 import shutil
 import tempfile
 import StringIO
-import md5
+from hashlib import md5
 import errno
 
 import unittest
@@ -25,7 +25,7 @@
     bz2 = None
 
 def md5sum(data):
-    return md5.new(data).hexdigest()
+    return md5(data).hexdigest()
 
 def path(path):
     return test_support.findfile(path)

Modified: python/trunk/Lib/uuid.py
==============================================================================
--- python/trunk/Lib/uuid.py	(original)
+++ python/trunk/Lib/uuid.py	Thu May 31 00:24:28 2007
@@ -506,8 +506,8 @@
 
 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():

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Thu May 31 00:24:28 2007
@@ -220,6 +220,8 @@
 Library
 -------
 
+- md5 now raises a DeprecationWarning upon import.
+
 - mimify now raises a DeprecationWarning upon import.
 
 - MimeWriter now raises a DeprecationWarning upon import.


More information about the Python-checkins mailing list