summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-05-31 19:20:00 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-05-31 19:20:00 (GMT)
commitc2aa09ad8055ba3e03da297608552d04b42e9aac (patch)
treed349deae79ade87b4e39098d067e114f50e1bcbb
parent03b75fa4e1331d4c9f5ff6385ff54fb522bc4cab (diff)
downloadcpython-c2aa09ad8055ba3e03da297608552d04b42e9aac.zip
cpython-c2aa09ad8055ba3e03da297608552d04b42e9aac.tar.gz
cpython-c2aa09ad8055ba3e03da297608552d04b42e9aac.tar.bz2
Have the sha module raise a DeprecationWarning as specified in PEP 4.
-rw-r--r--Lib/sha.py4
-rw-r--r--Lib/test/test_hmac.py10
-rw-r--r--Lib/test/test_pep247.py2
-rw-r--r--Lib/test/test_sha.py4
-rw-r--r--Lib/uuid.py4
-rw-r--r--Misc/NEWS2
6 files changed, 19 insertions, 7 deletions
diff --git a/Lib/sha.py b/Lib/sha.py
index 9d914a9..7e6d7af 100644
--- a/Lib/sha.py
+++ b/Lib/sha.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 sha module is deprecated; use the hashlib module instead",
+ DeprecationWarning, 2)
+
from hashlib import sha1 as sha
new = sha
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index 9d094d2..d28490d 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -1,5 +1,5 @@
import hmac
-import sha
+from hashlib import sha1
import unittest
from test import test_support
@@ -43,7 +43,7 @@ class TestVectorsTestCase(unittest.TestCase):
def test_sha_vectors(self):
def shatest(key, data, digest):
- h = hmac.HMAC(key, data, digestmod=sha)
+ h = hmac.HMAC(key, data, digestmod=sha1)
self.assertEqual(h.hexdigest().upper(), digest.upper())
shatest(chr(0x0b) * 20,
@@ -95,11 +95,11 @@ class ConstructorTestCase(unittest.TestCase):
def test_withmodule(self):
# Constructor call with text and digest module.
- import sha
+ from hashlib import sha1
try:
- h = hmac.HMAC("key", "", sha)
+ h = hmac.HMAC("key", "", sha1)
except:
- self.fail("Constructor call with sha module raised exception.")
+ self.fail("Constructor call with hashlib.sha1 raised exception.")
class SanityTestCase(unittest.TestCase):
diff --git a/Lib/test/test_pep247.py b/Lib/test/test_pep247.py
index 1eb9462..6add210 100644
--- a/Lib/test/test_pep247.py
+++ b/Lib/test/test_pep247.py
@@ -6,6 +6,8 @@
import warnings
warnings.filterwarnings("ignore", "the md5 module is deprecated.*",
DeprecationWarning)
+warnings.filterwarnings("ignore", "the sha module is deprecated.*",
+ DeprecationWarning)
import md5, sha, hmac
diff --git a/Lib/test/test_sha.py b/Lib/test/test_sha.py
index ea224e4..0647db3 100644
--- a/Lib/test/test_sha.py
+++ b/Lib/test/test_sha.py
@@ -4,6 +4,10 @@
# Publication 180-1, Secure Hash Standard, 1995 April 17
# http://www.itl.nist.gov/div897/pubs/fip180-1.htm
+import warnings
+warnings.filterwarnings("ignore", "the sha module is deprecated.*",
+ DeprecationWarning)
+
import sha
import unittest
from test import test_support
diff --git a/Lib/uuid.py b/Lib/uuid.py
index eb12d78..e21b070 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -529,8 +529,8 @@ def uuid4():
def uuid5(namespace, name):
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
- import sha
- hash = sha.sha(namespace.bytes + name).digest()
+ from hashlib import sha1
+ hash = sha1(namespace.bytes + name).digest()
return UUID(bytes=hash[:16], version=5)
# The following standard UUIDs are for use with uuid3() or uuid5().
diff --git a/Misc/NEWS b/Misc/NEWS
index c1f3763..740602b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -220,6 +220,8 @@ Core and builtins
Library
-------
+- sha now raises a DeprecationWarning upon import.
+
- md5 now raises a DeprecationWarning upon import.
- mimify now raises a DeprecationWarning upon import.