-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-90868: Add _PyStaticObject_CheckRefcnt() function #99261
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
Conversation
@ericsnowcurrently @kumaraditya303: This PR makes _PyStaticObjects_CheckRefcnt() more readable and shorter, what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one suggestion. Otherwise this looks good.
static inline void | ||
_PyStaticObject_CheckRefcnt(PyObject *obj) { | ||
if (Py_REFCNT(obj) < _PyObject_IMMORTAL_REFCNT) { | ||
_PyObject_ASSERT_FAILED_MSG(obj, | ||
"immortal object has less refcnt than expected " | ||
"_PyObject_IMMORTAL_REFCNT"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather that being part of the generated code, you could put this directly in pycore_global_objects_fini_generated.h, before the /* The following is auto-generated by Tools/build/generate_global_objects.py. */
marker line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, I didn't notice that only some parts of this file are generated. Ok, I added my new function at the top.
When you're done making the requested changes, leave the comment: |
Add _PyStaticObject_CheckRefcnt() function to make _PyStaticObjects_CheckRefcnt() shorter. Use _PyObject_ASSERT_FAILED_MSG() to log the object causing the fatal error.
I have made the requested changes; please review again. |
Thanks for making the requested changes! @ericsnowcurrently: please review the changes made to this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Merged, thanks for the review. |
Add _PyStaticObject_CheckRefcnt() function to make _PyStaticObjects_CheckRefcnt() shorter. Use
_PyObject_ASSERT_FAILED_MSG() to log the object causing the fatal error.