gh-144330: Initialize staticmethod/classmethod callables in tp_new#144440
Closed
Aniketsy wants to merge 3 commits intopython:mainfrom
Closed
gh-144330: Initialize staticmethod/classmethod callables in tp_new#144440Aniketsy wants to merge 3 commits intopython:mainfrom
Aniketsy wants to merge 3 commits intopython:mainfrom
Conversation
Contributor
Author
|
@vstinner Apologies for the previous PR. I’ve addressed the review suggestions in this one. Thanks! |
vstinner
reviewed
Feb 4, 2026
| if (cm == NULL) { | ||
| return NULL; | ||
| } | ||
| cm->cm_callable = Py_None; |
Member
There was a problem hiding this comment.
With this change, cm->cm_callable cannot be NULL anymore:
- cm_repr(): So you can remove
cm->cm_callable != NULL(revert your change). - cm_dealloc():
Py_XDECREF(cm->cm_callable);can be replaced withPy_DECREF(cm->cm_callable);. - cm_descr_get(): I suggest to replace
if (cm->cm_callable == NULL)withif (cm->cm_callable == Py_None). - cm_init(): replace
Py_XSETREF(cm->cm_callable, ...)withPy_SETREF(cm->cm_callable, ...).
Member
|
I wrote a different approach: parse arguments in cm_new()/sm_new(): PR gh-144469. |
Member
|
I merged #144469 instead. Thanks for your contribution anyway! |
Member
|
I wrote a simpler change for 3.13 and 3.14: #144498 I added you as a co-author since I copied some code from your PR. |
Contributor
Author
|
Thanks |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#144364
classmethodandstaticmethodcan crash withNULL/ uninitialized callables #144330