gh-113318: Support @deleter as a separate function in Argument Clinic - #157815
Draft
serhiy-storchaka wants to merge 1 commit into
Draft
serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
…Clinic Used alone, the @deleter directive defines a function which deletes the attribute. It can be combined with a @Setter defined in a separate block: the setter slot of the entry is then filled with a function which dispatches to one of them depending on whether the value is NULL. function.__annotations__ is now implemented in this way.
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.
Used alone, the
@deleterdirective defines a function which deletes the attribute. It can be combined with a@setterdefined in a separate block: the setter slot of thePyGetSetDefentry is then filled with a generated dispatcher which calls the setter or the deleter depending on whether the value isNULL.The two impl functions get distinct C names (
..._set_impland..._del_impl), so neither has to handle the other's case, and a setter that has a separate deleter no longer contains a deadif (arg == NULL)check for a case that the dispatcher never passes to it.function.__annotations__is converted as the first user: the deleter is a separate@deleterblock, and the setter is left with only the None-or-dict logic.There are now 36
@setterand 6@deleteruses in the tree. 30 setters reject deletion with the generatedAttributeError, 5 are combined with@deleterin the same block and handleNULLthemselves (frame.f_trace,_ctypes.CType_Type.__pointer_type__,_ctypes.CFuncPtr.errcheck,.restype,.argtypes), andfunction.__annotations__uses the new separate@deleter.@getterand@setter#113318