From 6acd96ae3b76a79297f7d51e6b80c2b92b0f1d3a Mon Sep 17 00:00:00 2001 From: Saki Date: Sat, 15 Aug 2026 08:30:22 -0300 Subject: [PATCH 1/2] Update list of files generated by `generate_token.py` (#155524) Co-authored-by: Stan Ulbrych --- .gitattributes | 2 +- Tools/build/generate_token.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index f00d82e6978c40..7ca49c3e44fe4b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -80,12 +80,12 @@ Include/internal/pycore_ast_state.h generated Include/internal/pycore_opcode.h generated Include/internal/pycore_opcode_metadata.h generated Include/internal/pycore_*_generated.h generated +Include/internal/pycore_token.h generated Include/internal/pycore_uop_ids.h generated Include/internal/pycore_uop_metadata.h generated Include/opcode.h generated Include/opcode_ids.h generated Include/slots_generated.h generated -Include/token.h generated Lib/_opcode_metadata.py generated Lib/idlelib/help.html generated Lib/keyword.py generated diff --git a/Tools/build/generate_token.py b/Tools/build/generate_token.py index 9ee5ec86e75d47..9bc96d338fdafa 100755 --- a/Tools/build/generate_token.py +++ b/Tools/build/generate_token.py @@ -5,7 +5,7 @@ # Doc/library/token-list.inc # Doc/library/token.rst (checked, not generated) # make_h: -# Include/token.h +# Include/internal/pycore_token.h # make_c: # Parser/token.c # make_py: From 948fd7e5c084274c3945d2004a7fffd19c907a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sat, 15 Aug 2026 14:00:27 +0200 Subject: [PATCH 2/2] gh-155430: fix `hmac.digest` bigmem test (#155431) --- Lib/test/test_hmac.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py index 1ea182fec4ff18..c43188cc333e88 100644 --- a/Lib/test/test_hmac.py +++ b/Lib/test/test_hmac.py @@ -1459,19 +1459,25 @@ class OperatorCompareDigestTestCase(CompareDigestMixin, unittest.TestCase): class PyMiscellaneousTests(unittest.TestCase): """Miscellaneous tests for the pure Python HMAC module.""" + @staticmethod + def mock__compute_digest_fallback(hmac): + fn = getattr(hmac, meth := "_compute_digest_fallback") + return patch.object(hmac, meth, wraps=fn) + + @staticmethod + def mock_HMAC_method(hmac, method): + fn = getattr(hmac.HMAC, method) + return patch.object(hmac.HMAC, method, autospec=True, wraps=fn) + @hashlib_helper.requires_builtin_hmac() def test_hmac_constructor_uses_builtin(self): # Block the OpenSSL implementation and check that # HMAC() uses the built-in implementation instead. hmac = import_fresh_module("hmac", blocked=["_hashlib"]) - def watch_method(cls, name): - wraps = getattr(cls, name) - return patch.object(cls, name, autospec=True, wraps=wraps) - with ( - watch_method(hmac.HMAC, '_init_openssl_hmac') as f, - watch_method(hmac.HMAC, '_init_builtin_hmac') as g, + self.mock_HMAC_method(hmac, '_init_openssl_hmac') as f, + self.mock_HMAC_method(hmac, '_init_builtin_hmac') as g, ): _ = hmac.HMAC(b'key', b'msg', digestmod="sha256") f.assert_not_called() @@ -1542,11 +1548,11 @@ def do_test_hmac_digest_overflow_error_switch_to_slow(self, hmac, size): bigkey = b'K' * size bigmsg = b'M' * size - with patch.object(hmac, "_compute_digest_fallback") as slow: + with self.mock__compute_digest_fallback(hmac) as slow: hmac.digest(bigkey, b'm', "md5") slow.assert_called_once() - with patch.object(hmac, "_compute_digest_fallback") as slow: + with self.mock__compute_digest_fallback(hmac) as slow: hmac.digest(b'k', bigmsg, "md5") slow.assert_called_once() @@ -1557,7 +1563,7 @@ def test_hmac_digest_no_overflow_error_in_fallback(self, size): for key, msg in [(b'K' * size, b'm'), (b'k', b'M' * size)]: with self.subTest(keysize=len(key), msgsize=len(msg)): - with patch.object(hmac, "_compute_digest_fallback") as slow: + with self.mock__compute_digest_fallback(hmac) as slow: hmac.digest(key, msg, "md5") slow.assert_called_once()