summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-05-30 22:24:28 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-05-30 22:24:28 (GMT)
commit7eec2179081c86e1a79c5f17b43346e14fc8fb53 (patch)
treedb14dd573c2ec2801d4a622440f7d47235bec19f
parentc249bdab92cc6fd933fb4972356a3fb0a0865ec4 (diff)
downloadcpython-7eec2179081c86e1a79c5f17b43346e14fc8fb53.zip
cpython-7eec2179081c86e1a79c5f17b43346e14fc8fb53.tar.gz
cpython-7eec2179081c86e1a79c5f17b43346e14fc8fb53.tar.bz2
Have md5 raise a DeprecationWarning as per PEP 4.
-rw-r--r--Lib/md5.py4
-rw-r--r--Lib/test/test_md5.py3
-rw-r--r--Lib/test/test_pep247.py4
-rw-r--r--Lib/test/test_tarfile.py4
-rw-r--r--Lib/uuid.py4
-rw-r--r--Misc/NEWS2
6 files changed, 17 insertions, 4 deletions
diff --git a/Lib/md5.py b/Lib/md5.py
index bbe1984..f6433cc 100644
--- a/Lib/md5.py
+++ b/Lib/md5.py
@@ -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
diff --git a/Lib/test/test_md5.py b/Lib/test/test_md5.py
index 1f08568..2c0e8e2 100644
--- a/Lib/test/test_md5.py
+++ b/Lib/test/test_md5.py
@@ -1,4 +1,7 @@
# Testing md5 module
+import warnings
+warnings.filterwarnings("ignore", "the md5 module is deprecated.*",
+ DeprecationWarning)
import unittest
from md5 import md5
diff --git a/Lib/test/test_pep247.py b/Lib/test/test_pep247.py
index 88f2461..1eb9462 100644
--- a/Lib/test/test_pep247.py
+++ b/Lib/test/test_pep247.py
@@ -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):
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 04f9ba5..67e52e9 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -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)
diff --git a/Lib/uuid.py b/Lib/uuid.py
index ae3da25..eb12d78 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -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():
diff --git a/Misc/NEWS b/Misc/NEWS
index 8f4bceb..c1f3763 100644
--- 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.