https://github.com/python/cpython/commit/b20722c300a78c38462081a3f1c45190b5434e71
commit: b20722c300a78c38462081a3f1c45190b5434e71
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-12-09T17:03:13+01:00
summary:

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.

files:
M Include/internal/pycore_backoff.h
M Lib/test/test_cppext/extension.cpp

diff --git a/Include/internal/pycore_backoff.h 
b/Include/internal/pycore_backoff.h
index 7f60eb495080ae..23ca7299e0d2bd 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 1affa176088d57..f95655eccded61 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
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to