gh-113318: Fix @getter and @setter in Argument Clinic - #155778
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-113318: Fix @getter and @setter in Argument Clinic#155778serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
Fix generating an accessor in a preprocessor conditional block. Reject the accessors of the same attribute with different C basenames and the same accessor defined twice. Reject deletion of the attribute, which crashed the setter, unless the new directive @deleter is applied to it.
serhiy-storchaka
requested review from
1st1,
AA-Turner,
asvetlov,
erlend-aasland,
iritkatriel,
kumaraditya303,
markshannon and
willingc
as code owners
August 14, 2026 10:10
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.
Three fixes for the accessors generated by Argument Clinic:
@getteror a@setterin a preprocessor conditional block failed withKeyError: 'methoddef_name', because the fallback definition was emitted for theMETHODDEFsymbol instead of theGETSETDEFone.PyGetSetDefis identified by the C basename shared by the accessors, so defining them with different C basenames (Foo.p as foo_getandFoo.p as foo_set), or defining the same accessor twice, silently generated invalid or duplicated entries. It is now an error.NULLto delete the attribute. Implementations which did not check for it crashed --frame.f_trace_opcodesand thecontext,ownerandsessionattributes of_ssl._SSLSocket-- or reported a confusingSystemError. Deletion is now rejected withAttributeError, unless the new directive@deleteris applied to the setter, which is then called withNULLas before.@deleteris applied to the 22 setters whose implementation is written to acceptNULL, so deleting these attributes works as before. Only three generated files change: the setters of_ssl,_sqlite3.Cursor.arraysizeandframe.f_trace_opcodesgain the deletion check.@getterand@setter#113318