From: Gregory P. Smith Date: Sun, 22 Jul 2012 04:22:16 +0000 (-0700) Subject: Consistently raise a TypeError when a non str is passed to hashlib.new X-Git-Tag: v2.7.5~109^2~438 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9e9e0d5a8be470ade2bb497019a5cf737138182;p=python Consistently raise a TypeError when a non str is passed to hashlib.new regardless of which of the two implementations of new is used. --- diff --git a/Lib/hashlib.py b/Lib/hashlib.py index 2732d184aa..d20e1f95a2 100644 --- a/Lib/hashlib.py +++ b/Lib/hashlib.py @@ -88,7 +88,7 @@ def __get_builtin_constructor(name): 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 index 95bf0b347c..f5c242e6c9 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -128,6 +128,7 @@ class HashLibTestCase(unittest.TestCase): 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: