Skip to content
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

bpo-40024: Add PyModule_AddType() helper function #19088

Merged
merged 6 commits into from
Mar 22, 2020

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Mar 20, 2020

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.

IMHO such helper function deserves to be added to the limited C API. I know that I said the opposite a few days ago ;-) But now I can review its implementation and how it's used in practice ;-)

Modules/_weakref.c would also benefit of this helper function. Well, I get that almost all C extension would benefit of this helper. But let's start with the current PR + _weakref, and then write a second PR to convert all other C extension to PyModule_AddType() at once.

Include/modsupport.h Outdated Show resolved Hide resolved
@corona10
Copy link
Member Author

@vstinner
Hey Victor, unfortunately, _weakref is not the case for this time.
For example _PyWeakref_RefType tp_name is weakref but on _weakref.c adds this type object as ref.
So I add the new case with _lzmamodule for this function.

@corona10 corona10 requested a review from vstinner March 21, 2020 14:26
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.

Can you please rename _PyModule_AddType to PyModule_AddType() to make it public? Names starting with _Py are private functions.

Doc/c-api/module.rst Show resolved Hide resolved
@vstinner vstinner changed the title bpo-40024: Add _PyModule_AddType helper function. bpo-40024: Add PyModule_AddType() helper function Mar 21, 2020
Python/modsupport.c Outdated Show resolved Hide resolved
Modules/_collectionsmodule.c Outdated Show resolved Hide resolved
@corona10 corona10 requested a review from vstinner March 22, 2020 06:48
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. Just a last request on the documentation.

Doc/c-api/module.rst Outdated Show resolved Hide resolved
Co-Authored-By: Victor Stinner <vstinner@python.org>
@corona10
Copy link
Member Author

@vstinner
Thanks for the review. I apply the suggestion!

@vstinner vstinner merged commit 05e4a29 into python:master Mar 22, 2020
@vstinner
Copy link
Member

Merged, thanks.

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.

4 participants