Skip to content

Fix new 3.14 C API deprecation for _PyLong_Sign #2603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented May 9, 2025

Addresses a Python C API Deprecation listed in #2588

Comment on lines +142 to +145
int sign;
if (!PyLong_GetSign(obj, sign)) {
return NULL
}
Copy link
Collaborator Author

@Avasam Avasam May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My lack of C++ expertise will show here, but according to the doc: https://docs.python.org/3.14/c-api/long.html#c.PyLong_GetSign

On failure, return -1 with an exception set.

So iiuc, to properly bubble up that exception, I just have to return NULL ? Or is there something else I need to do as well.

Note that the rest of this function always returns FALSE when PyErr_Occurred(). So maybe I want to return FALSE here as well for consistency ?

@Avasam Avasam mentioned this pull request May 9, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant