Update hmac from v3.14.3

This commit is contained in:
CPython Developers authored and Jeong, YunWon committed 2026-02-15 21:04:32 +09:00
1 parent 1d0c8130bb
commit c10cbc9be7
2 files changed
+22 -13

No files matched your search

Vendored
+1
View File
@@ -159,6 +159,7 @@ class HMAC:
# Call __new__ directly to avoid the expensive __init__.
other = self.__class__.__new__(self.__class__)
other.digest_size = self.digest_size
other.block_size = self.block_size
if self._hmac:
other._hmac = self._hmac.copy()
other._inner = other._outer = None
+21 -13
View File
@@ -1066,6 +1066,14 @@ class OpenSSLConstructorTestCase(ThroughOpenSSLAPIMixin,
):
self.hmac_digest(b'key', b'msg', value)
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'HMAC'. Did you mean: 'exc_type'?
def test_internal_types(self):
return super().test_internal_types()
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'hmac_digest'
def test_digest(self):
return super().test_digest()
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_constructor(self):
return super().test_constructor()
@@ -1078,14 +1086,6 @@ class OpenSSLConstructorTestCase(ThroughOpenSSLAPIMixin,
def test_constructor_unknown_digestmod(self):
return super().test_constructor_unknown_digestmod()
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'HMAC'. Did you mean: 'exc_type'?
def test_internal_types(self):
return super().test_internal_types()
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'hmac_digest'
def test_digest(self):
return super().test_digest()
class BuiltinConstructorTestCase(ThroughBuiltinAPIMixin,
ExtensionConstructorTestCaseMixin,
@@ -1137,6 +1137,15 @@ class SanityTestCaseMixin(CreatorMixin):
self.assertEqual(h.digest_size, self.digest_size)
self.assertEqual(h.block_size, self.block_size)
def test_copy(self):
# Test a generic copy() and the attributes it exposes.
# See https://github.com/python/cpython/issues/142451.
h1 = self.hmac_new(b"my secret key", digestmod=self.digestname)
h2 = h1.copy()
self.assertEqual(h1.name, h2.name)
self.assertEqual(h1.digest_size, h2.digest_size)
self.assertEqual(h1.block_size, h2.block_size)
def test_repr(self):
# HMAC object representation may differ across implementations
raise NotImplementedError
@@ -1160,7 +1169,6 @@ class PySanityTestCase(ThroughObjectMixin, PyModuleMixin, SanityTestCaseMixin,
@hashlib_helper.requires_openssl_hashdigest('sha256')
@unittest.skip("TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'HMAC'")
class OpenSSLSanityTestCase(ThroughOpenSSLAPIMixin, SanityTestCaseMixin,
unittest.TestCase):
@@ -1257,10 +1265,6 @@ class OpenSSLUpdateTestCase(UpdateTestCaseMixin, unittest.TestCase):
def gil_minsize(self):
return _hashlib._GIL_MINSIZE
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_update(self):
return super().test_update()
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute '_GIL_MINSIZE'
def test_update_large(self):
return super().test_update_large()
@@ -1269,6 +1273,10 @@ class OpenSSLUpdateTestCase(UpdateTestCaseMixin, unittest.TestCase):
def test_update_exceptions(self):
return super().test_update_exceptions()
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_update(self):
return super().test_update()
class BuiltinUpdateTestCase(BuiltinModuleMixin,
UpdateTestCaseMixin, unittest.TestCase):