-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-5033 Use PyModule_Add on >= 3.13 #2332
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
Conversation
bson/_cbsonmodule.c
Outdated
@@ -3227,11 +3227,19 @@ _cbson_exec(PyObject *m) | |||
INITERROR; | |||
} | |||
|
|||
#if PY_VERSION_HEX >= 0x030D0000 | |||
if (PyModule_Add(m, "_C_API", c_api_object) < 0) { | |||
Py_DECREF(c_api_object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to remove this decref, the new API always steals the reference: https://docs.python.org/3/c-api/module.html#c.PyModule_Add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You removed the wrong line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again, you removed the wrong line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 In 75233bb I only added two DECREFs … identical to the DECREFs in the else
clause. Are you saying we need to remove a DECREF from somewhere else, unrelated to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to decref m
here, not c_api_object
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK but that was already done in 9c768f5 and you said that I removed the wrong one … 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it was not done in 9c768f5 .
That commit removes code in a completely unrelated code block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! Sorry about that, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. FYI you should only resolve your own comments, not other people's. That way the reviewers can double check their comment is resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the tests pass
PYTHON-5033