Skip to content

Commit b20722c

Browse files
authored
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.
1 parent 1b460fc commit b20722c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Include/internal/pycore_backoff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern "C" {
4040
#define MAX_VALUE 0x1FFF
4141

4242
#define MAKE_VALUE_AND_BACKOFF(value, backoff) \
43-
((value << BACKOFF_BITS) | backoff)
43+
((uint16_t)(((value) << BACKOFF_BITS) | (backoff)))
4444

4545
// For previous backoff b we use value x such that
4646
// x + 1 is near to 2**(2*b+1) and x + 1 is prime.

Lib/test/test_cppext/extension.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#ifdef TEST_INTERNAL_C_API
1616
// gh-135906: Check for compiler warnings in the internal C API
17+
# include "internal/pycore_backoff.h"
1718
# include "internal/pycore_frame.h"
1819
#endif
1920

0 commit comments

Comments
 (0)