Repository navigation
gh-90763: Modernise xx template module initialisation - #93078
Conversation
Use C APIs such as PyModule_AddType instead of PyModule_AddObject. Also remove incorrect module decrefs if module fails to initialise.
|
@corona10, would you mind reviewing this? It's been a while since I've done the module init ref count dances :) I note that xxlimited_35 creates two objects from the same type spec. I'm not sure if there's a point in doing that. |
commented
May 23, 2022
|
Thanks, Dong-hee! I'll hold the merge a couple of days to give Petr (or Victor) a chance to review. |
commented
May 23, 2022
|
Looks good, thanks! |
commented
May 23, 2022
I had to ponder a little bit about this; I agree that it's worth it keeping the changes minimal for these modules :) |
commented
May 23, 2022
The file starts with:
IMO it should be a show case of the best practice to write a C extension in 2022. Otherwise, people will continue to copy/paste this old code and will propagate static types and other legacy code to their project :-( |
commented
May 23, 2022
|
If you want to test that the old way to write a C extension, with static types and global variables, still work, IMO it should be another module than this "template". |
We could adjust the wording in the top of the file, and also rename it to something like
That's what the xxlimited.c module is :) |
commented
May 24, 2022
|
Anyway, the more important thing to do here is converting the tutorial. That will, in my opinion, make the new way official :) But yes, all that is out of scope of this PR. |
commented
Jun 9, 2022
|
FYI, I plan to merge this tomorrow. |
commented
Jun 10, 2022
|
I'm fine with backporting the whole PR. Most changes are related to the bugfix. |
commented
Jun 10, 2022
|
Thanks @erlend-aasland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
commented
Jun 10, 2022
|
Thanks @erlend-aasland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
commented
Jun 10, 2022
|
Sorry @erlend-aasland, I had trouble checking out the |
commented
Jun 10, 2022
|
GH-93679 is a backport of this pull request to the 3.10 branch. |
commented
Jun 10, 2022
|
GH-93681 is a backport of this pull request to the 3.11 branch. |
xxmodule:
xxlimited_35: