Skip to content

bpo-41798: Allocate socket extension module CAPI on the heap #24126

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 2 commits into from
Jan 6, 2021

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Jan 5, 2021

@erlend-aasland
Copy link
Contributor Author

cc. @tiran / @shihai1991

Py_DECREF(m);
return NULL;
}
if (PyModule_AddObject(m, PySocket_CAPI_NAME, capsule) < 0) {
Copy link
Member

Choose a reason for hiding this comment

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

How about using PyModule_AddObjectRef() in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can leave it as it is for now. We can do a thorough clean up of the module init function when we convert it to multi-phase init. Ok?

Copy link
Member

Choose a reason for hiding this comment

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

No problem.

@@ -342,7 +342,8 @@ typedef struct {

*/

/* C API for usage by other Python modules */
/* C API for usage by other Python modules.
* Always add new things to the end for binary compatibility. */
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure this note is correct or not. The binary compatibilty also depends how to use it, no?

Copy link
Contributor Author

@erlend-aasland erlend-aasland Jan 6, 2021

Choose a reason for hiding this comment

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

You're right. I just copied the comment from the .c file. I figured it made more sense together with the definition in the header file. However, I don't think this comment is really needed. I'd recommend just deleting it.

Copy link
Member

Choose a reason for hiding this comment

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

In case of doubt, I prefer to keep it. It makes sense to only add new members at the end. If a C extension is built with Python 3.10 and a new filed is added to Python 3.11, the Python 3.10 remains ABI compatible. The comment looks correct.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -342,7 +342,8 @@ typedef struct {

*/

/* C API for usage by other Python modules */
/* C API for usage by other Python modules.
* Always add new things to the end for binary compatibility. */
Copy link
Member

Choose a reason for hiding this comment

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

In case of doubt, I prefer to keep it. It makes sense to only add new members at the end. If a C extension is built with Python 3.10 and a new filed is added to Python 3.11, the Python 3.10 remains ABI compatible. The comment looks correct.

@vstinner vstinner merged commit f22b7ca into python:master Jan 6, 2021
@erlend-aasland erlend-aasland deleted the bpo-41798/socket branch January 6, 2021 19:48
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants