mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Consistently raise a TypeError when a non str is passed to hashlib.new
regardless of which of the two implementations of new is used.
This commit is contained in:
commit
34fcafde16
2 changed files with 2 additions and 1 deletions
|
@ -88,7 +88,7 @@ def __get_builtin_constructor(name):
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass # no extension module, this hash is unsupported.
|
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):
|
def __get_openssl_constructor(name):
|
||||||
|
|
|
@ -133,6 +133,7 @@ class HashLibTestCase(unittest.TestCase):
|
||||||
sys.modules['_md5'] = _md5
|
sys.modules['_md5'] = _md5
|
||||||
else:
|
else:
|
||||||
del sys.modules['_md5']
|
del sys.modules['_md5']
|
||||||
|
self.assertRaises(TypeError, get_builtin_constructor, 3)
|
||||||
|
|
||||||
def test_hexdigest(self):
|
def test_hexdigest(self):
|
||||||
for name in self.supported_hash_names:
|
for name in self.supported_hash_names:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue