Skip to content

Commit b86926d

Browse files
CPython Developersgithub-actions[bot]
authored andcommitted
Update hmac from v3.14.3
1 parent dd422a8 commit b86926d

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

Lib/hmac.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def copy(self):
159159
# Call __new__ directly to avoid the expensive __init__.
160160
other = self.__class__.__new__(self.__class__)
161161
other.digest_size = self.digest_size
162+
other.block_size = self.block_size
162163
if self._hmac:
163164
other._hmac = self._hmac.copy()
164165
other._inner = other._outer = None

Lib/test/test_hmac.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,14 @@ def test_hmac_digest_digestmod_parameter(self):
10661066
):
10671067
self.hmac_digest(b'key', b'msg', value)
10681068

1069+
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'HMAC'. Did you mean: 'exc_type'?
1070+
def test_internal_types(self):
1071+
return super().test_internal_types()
1072+
1073+
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'hmac_digest'
1074+
def test_digest(self):
1075+
return super().test_digest()
1076+
10691077
@unittest.expectedFailure # TODO: RUSTPYTHON
10701078
def test_constructor(self):
10711079
return super().test_constructor()
@@ -1078,14 +1086,6 @@ def test_constructor_missing_digestmod(self):
10781086
def test_constructor_unknown_digestmod(self):
10791087
return super().test_constructor_unknown_digestmod()
10801088

1081-
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'HMAC'. Did you mean: 'exc_type'?
1082-
def test_internal_types(self):
1083-
return super().test_internal_types()
1084-
1085-
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'hmac_digest'
1086-
def test_digest(self):
1087-
return super().test_digest()
1088-
10891089

10901090
class BuiltinConstructorTestCase(ThroughBuiltinAPIMixin,
10911091
ExtensionConstructorTestCaseMixin,
@@ -1137,6 +1137,15 @@ def test_properties(self):
11371137
self.assertEqual(h.digest_size, self.digest_size)
11381138
self.assertEqual(h.block_size, self.block_size)
11391139

1140+
def test_copy(self):
1141+
# Test a generic copy() and the attributes it exposes.
1142+
# See https://github.com/python/cpython/issues/142451.
1143+
h1 = self.hmac_new(b"my secret key", digestmod=self.digestname)
1144+
h2 = h1.copy()
1145+
self.assertEqual(h1.name, h2.name)
1146+
self.assertEqual(h1.digest_size, h2.digest_size)
1147+
self.assertEqual(h1.block_size, h2.block_size)
1148+
11401149
def test_repr(self):
11411150
# HMAC object representation may differ across implementations
11421151
raise NotImplementedError
@@ -1160,7 +1169,6 @@ def test_repr(self):
11601169

11611170

11621171
@hashlib_helper.requires_openssl_hashdigest('sha256')
1163-
@unittest.skip("TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute 'HMAC'")
11641172
class OpenSSLSanityTestCase(ThroughOpenSSLAPIMixin, SanityTestCaseMixin,
11651173
unittest.TestCase):
11661174

@@ -1257,10 +1265,6 @@ def HMAC(self, key, msg=None):
12571265
def gil_minsize(self):
12581266
return _hashlib._GIL_MINSIZE
12591267

1260-
@unittest.expectedFailure # TODO: RUSTPYTHON
1261-
def test_update(self):
1262-
return super().test_update()
1263-
12641268
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module '_hashlib' has no attribute '_GIL_MINSIZE'
12651269
def test_update_large(self):
12661270
return super().test_update_large()
@@ -1269,6 +1273,10 @@ def test_update_large(self):
12691273
def test_update_exceptions(self):
12701274
return super().test_update_exceptions()
12711275

1276+
@unittest.expectedFailure # TODO: RUSTPYTHON
1277+
def test_update(self):
1278+
return super().test_update()
1279+
12721280

12731281
class BuiltinUpdateTestCase(BuiltinModuleMixin,
12741282
UpdateTestCaseMixin, unittest.TestCase):

0 commit comments

Comments
 (0)