FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-86493: Use PyModule_Add() instead of PyModule_AddObjectRef() by serhiy-storchaka · Pull Request #106860 · python/cpython · GitHub

Repository navigation

gh-86493: Use PyModule_Add() instead of PyModule_AddObjectRef() - #106860

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:use-PyModule_Add2
Jul 18, 2023
Merged

serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:use-PyModule_Add2

Conversation

serhiy-storchaka commented Jul 18, 2023 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

If PyModule_AddObjectRef() followed by Py_DECREF() of the added value, the code can be simplified by using PyModule_Add() which was designed specially for such cases.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

Comment thread Modules/_testcapi/mem.c
int rc = PyModule_AddObjectRef(mod, "WITH_PYMALLOC", v);
Py_DECREF(v);
if (rc < 0) {
if (PyModule_AddObjectRef(mod, "WITH_PYMALLOC", v) < 0) {

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Was this purposefully not converted to PyModule_Add()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, PyModule_AddObjectRef() is more fitting here. But the old code was complicated without need.

serhiy-storchaka merged commit a293fa5 into python:main Jul 18, 2023
serhiy-storchaka deleted the use-PyModule_Add2 branch July 18, 2023 20:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL