Skip to content

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

Merged
merged 6 commits into from
May 8, 2025

Conversation

aclark4life
Copy link
Contributor

@aclark4life aclark4life commented May 2, 2025

@aclark4life aclark4life marked this pull request as ready for review May 8, 2025 18:32
@aclark4life aclark4life requested a review from ShaneHarvey May 8, 2025 18:32
@@ -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);
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😂

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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 … 🤔

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

@aclark4life aclark4life requested a review from ShaneHarvey May 8, 2025 19:41
Copy link
Member

@ShaneHarvey ShaneHarvey left a 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

@aclark4life aclark4life merged commit 2655bb4 into mongodb:master May 8, 2025
30 checks passed
@aclark4life aclark4life deleted the PYTHON-5033 branch May 8, 2025 21:14
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.

2 participants