Fix compilation warnings on Python 3.15 - #1077
Merged
Merged
Conversation
sobolevn
reviewed
Jun 16, 2026
| #if PY314_PLUS | ||
| /* obj is always a PyLong here, so PyLong_GetSign can't fail */ | ||
| int sign = 0; | ||
| PyLong_GetSign(obj, &sign); |
Member
There was a problem hiding this comment.
It is better to use explicit (void)PyLong_GetSign(obj, &sign); to tell that we ignore the result value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Silences three compiler warnings seen on 3.15-dev (and reproducible on 3.14):
_constr_as_i64:(-1LL << 63)is a left shift of a negative value (UB,-Wshift-negative-value). Replaced withINT64_MIN, which is the value it was computing.double_as_int64:(-1LL << 53)is the same UB. Replaced with-(1LL << 53)(negate a positive shift), keeping the exact-2**53bound.ms_passes_big_int_constraints:_PyLong_SignisPy_DEPRECATED(3.14). Use the publicPyLong_GetSignon 3.14+ and keep_PyLong_Signon older versions.All three are behavior preserving. Built and ran the unit suite on both branches: 3.12 (
_PyLong_Sign) and 3.14 (PyLong_GetSign), both green; the three warnings are gone under 3.14 headers.Note: the reporter's paste also mentions "1 error" alongside the warnings. That is an
SSIZE_MAX undeclaredfrom CPython's 3.15pyport.hwhen_core.cis compiled in isolation without_GNU_SOURCE; it doesn't reproduce under the normal build (CPython'spyconfig.hsets the feature-test macros), so it's out of scope here.Closes #1048