[Python-checkins] cpython (2.7): Consistently raise a TypeError when a non str is passed to hashlib.new
gregory.p.smith
python-checkins at python.org
Sun Jul 22 06:23:25 CEST 2012
http://hg.python.org/cpython/rev/21691763ab3b
changeset: 78237:21691763ab3b
branch: 2.7
parent: 78139:cd2d4fe57c0e
user: Gregory P. Smith <greg at krypto.org>
date: Sat Jul 21 21:22:16 2012 -0700
summary:
Consistently raise a TypeError when a non str is passed to hashlib.new
regardless of which of the two implementations of new is used.
files:
Lib/hashlib.py | 2 +-
Lib/test/test_hashlib.py | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
--- a/Lib/hashlib.py
+++ b/Lib/hashlib.py
@@ -88,7 +88,7 @@
except ImportError:
pass # no extension module, this hash is unsupported.
- raise ValueError('unsupported hash type %s' % name)
+ raise ValueError('unsupported hash type ' + name)
def __get_openssl_constructor(name):
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -128,6 +128,7 @@
sys.modules['_md5'] = _md5
else:
del sys.modules['_md5']
+ self.assertRaises(TypeError, get_builtin_constructor, 3)
def test_hexdigest(self):
for name in self.supported_hash_names:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list