diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2009-02-12 07:35:29 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2009-02-12 07:35:29 (GMT) |
commit | 365a1864fd285fc6ee9d9fa1f8770b39d4dab830 (patch) | |
tree | 0fb2cf9664348d80caa3e3ace86b84aa2a3f9080 /Lib/test/test_hashlib.py | |
parent | 3072921d0e668e890da1312e0f47f3e7e4854329 (diff) | |
download | cpython-365a1864fd285fc6ee9d9fa1f8770b39d4dab830.zip cpython-365a1864fd285fc6ee9d9fa1f8770b39d4dab830.tar.gz cpython-365a1864fd285fc6ee9d9fa1f8770b39d4dab830.tar.bz2 |
Fixes Issue #3745: Fix hashlib to always reject unicode and non
buffer-api supporting objects as input no matter how it was compiled
(built in implementations or external openssl library).
Diffstat (limited to 'Lib/test/test_hashlib.py')
-rw-r--r-- | Lib/test/test_hashlib.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index e69c704..9b51459 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -63,6 +63,18 @@ class HashLibTestCase(unittest.TestCase): computed = hashlib.new(name, data).hexdigest() self.assertEqual(computed, digest) + def check_no_unicode(self, algorithm_name): + # Unicode objects are not allowed as input. + self.assertRaises(TypeError, getattr(hashlib, algorithm_name), 'spam') + self.assertRaises(TypeError, hashlib.new, algorithm_name, 'spam') + + def test_no_unicode(self): + self.check_no_unicode('md5') + self.check_no_unicode('sha1') + self.check_no_unicode('sha224') + self.check_no_unicode('sha256') + self.check_no_unicode('sha384') + self.check_no_unicode('sha512') def test_case_md5_0(self): self.check('md5', b'', 'd41d8cd98f00b204e9800998ecf8427e') |