From b20722c300a78c38462081a3f1c45190b5434e71 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 9 Dec 2025 17:03:13 +0100 Subject: [PATCH] gh-142447: Fix cast warning in pycore_backoff.h (#142465) MAKE_VALUE_AND_BACKOFF() macro casts its result to uint16_t. Add pycore_backoff.h header to test_cppext tests. --- Include/internal/pycore_backoff.h | 2 +- Lib/test/test_cppext/extension.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Include/internal/pycore_backoff.h b/Include/internal/pycore_backoff.h index 7f60eb495080..23ca7299e0d2 100644 --- a/Include/internal/pycore_backoff.h +++ b/Include/internal/pycore_backoff.h @@ -40,7 +40,7 @@ extern "C" { #define MAX_VALUE 0x1FFF #define MAKE_VALUE_AND_BACKOFF(value, backoff) \ - ((value << BACKOFF_BITS) | backoff) + ((uint16_t)(((value) << BACKOFF_BITS) | (backoff))) // For previous backoff b we use value x such that // x + 1 is near to 2**(2*b+1) and x + 1 is prime. diff --git a/Lib/test/test_cppext/extension.cpp b/Lib/test/test_cppext/extension.cpp index 1affa176088d..f95655eccded 100644 --- a/Lib/test/test_cppext/extension.cpp +++ b/Lib/test/test_cppext/extension.cpp @@ -14,6 +14,7 @@ #ifdef TEST_INTERNAL_C_API // gh-135906: Check for compiler warnings in the internal C API +# include "internal/pycore_backoff.h" # include "internal/pycore_frame.h" #endif -- 2.47.3