◐ Shell
reader mode source ↗
Skip to content

gh-86493: Modernize modules initialization code#106858

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:use-PyModule_Add
Jul 25, 2023
Merged

gh-86493: Modernize modules initialization code#106858
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:use-PyModule_Add

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 18, 2023

Copy link
Copy Markdown
Member

Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated PyModule_AddObject().

PyModule_AddObject() is only left in two modules: _testcapi and _testbuffer. But that code ignores any failures for now. They need more significant rewriting.


📚 Documentation preview 📚: https://cpython-previews--106858.org.readthedocs.build/

Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated
PyModule_AddObject().

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

LGTM, but a few compiler warnings should be fixed first: see GHA job results, especially the Ubuntu job which logged many warnings.

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

lgtm too

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

LGTM. I didn't check individual refcount, I rely on Refleaks buildbots for that and other reviewers 😁 Overall the change LGTM and makes the code shorter and more regular. The old code was really hard to understand with INCREF/DECREF dance.

@rhettinger rhettinger removed their request for review July 20, 2023 13:49
@serhiy-storchaka serhiy-storchaka merged commit 329e4a1 into python:main Jul 25, 2023
@bedevere-bot bedevere-bot removed the label Jul 25, 2023
@serhiy-storchaka serhiy-storchaka deleted the use-PyModule_Add branch July 25, 2023 11:34
@vstinner

Copy link
Copy Markdown
Member

That's a big change, thanks.

jtcave pushed a commit to jtcave/cpython that referenced this pull request Jul 27, 2023
Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated
PyModule_AddObject().
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.

4 participants