mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +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:
parent
00528e8fec
commit
76c28f7ce2
2 changed files with 4 additions and 7 deletions
|
@ -111,12 +111,8 @@ class HashLibTestCase(unittest.TestCase):
|
|||
issubset(hashlib.algorithms_available))
|
||||
|
||||
def test_unknown_hash(self):
|
||||
try:
|
||||
hashlib.new('spam spam spam spam spam')
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
self.assertTrue(0 == "hashlib didn't reject bogus hash name")
|
||||
self.assertRaises(ValueError, hashlib.new, 'spam spam spam spam spam')
|
||||
self.assertRaises(TypeError, hashlib.new, 1)
|
||||
|
||||
def test_get_builtin_constructor(self):
|
||||
get_builtin_constructor = hashlib.__dict__[
|
||||
|
@ -135,6 +131,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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue