]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-142447: Fix cast warning in pycore_backoff.h (#142465)
authorVictor Stinner <vstinner@python.org>
Tue, 9 Dec 2025 16:03:13 +0000 (17:03 +0100)
committerGitHub <noreply@github.com>
Tue, 9 Dec 2025 16:03:13 +0000 (17:03 +0100)
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
Lib/test/test_cppext/extension.cpp

index 7f60eb495080ae3fdf98d191dc67a13482eb9b36..23ca7299e0d2bd7ee26d2e05a4a6cc0796df5b89 100644 (file)
@@ -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.
index 1affa176088d578de9ef77ae02c7ddd0c979a495..f95655eccded61843a839627ca61be0f055a08c4 100644 (file)
@@ -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