Repository navigation
Support getters and setters in Argument Clinic #112205
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement3.13only security fixesonly security fixes
on Nov 17, 2023 cc @aisk (who brought up this issue in #112116 (comment)) and @erlend-aasland for feedback
Another example that needs this feature: #112298
@colesbury @erlend-aasland @AlexWaygood
(Just for example)
What about following DSL fornamesetter / getter case?
It looks similar to Java lombok annotation :(/*[clinic input] @setter @getter @critical_section _io._Buffered.name [clinic start generated code]*/Reacted by Erlend E. Aasland/*[clinic input] @getter @critical_section _io._Buffered.name [clinic start generated code]*/ /*[clinic input] @setter @critical_section _io._Buffered.name [clinic start generated code]*/I am working on supporting
@setterwith the co-existence case of@getter.
Separating clinic input is more straightforward and cleaner than declaring with a single input.Reacted by Alex Waygood and Erlend E. AaslandSeparating clinic input is more straightforward and cleaner than declaring with a single input.
I think it looks nicer as well — having the three stacked decorators kinda looked ugly to me. Moreover, the slightly more verbose syntax of having the two inputs separated is closer to how you'd implement a Python property with a setter. In short: good choice, IMO :-)
Reacted by Erlend E. Aasland and Donghee Na- added a commit that references this issue
on Dec 10, 2023 13 remaining items
- added 6 commits that reference this issue
on Feb 11, 2024 - added 6 commits that reference this issue
on Sep 2, 2024
Feature or enhancement
In the C API, getters and setters are implemented using
PyGetSetDef. Argument Clinic doesn't currently support writing getters and setters, probably because they are pretty straightforward to write manually -- there's not much argument parsing to be done.Argument Clinic now supports the
@critical_sectiondirective, which avoids a bunch of boilerplate code when making things thread-safe with the--disable-gilbuilds. It would be helpful if Argument Clinic supported getters/setters so that we could avoid the critical section boilerplate in getters and setters as well.Linked PRs
@setterannotation from AC #112922@getteras possible. #113095@getter#113160