This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Argument Clinic: add 'self' return converter
Type: enhancement Stage: needs patch
Components: Argument Clinic Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, larry, serhiy.storchaka, zach.ware
Priority: low Keywords:

Created on 2014-01-27 18:30 by zach.ware, last changed 2022-04-11 14:57 by admin.

Messages (3)
msg209457 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-01-27 18:30
It would be nice to have a 'self' return converter for simple functions like winreg.HKEYType.__enter__ (which is implemented as "Py_XINCREF(self); return self;").  With the typedef and type_object specifications now required for the class directive, 'self' is passed to that function as a PyHKEYObject *, but impl is expected to return a PyObject *.

In this particular instance, I can solve the problem (which is a compiler warning) with a custom self_return_converter that casts _return_value to PyObject *.  I think a generic solution would be better in the long run and useful in more places, though.
msg342833 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2019-05-19 04:01
Doesn't clinic have a `self_converter` class? https://github.com/python/cpython/blame/master/Tools/clinic/clinic.py#L3465
msg350103 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-21 19:28
Batuhan, argument converters and return converters are different things.

I have no opinion about the idea itself. You can try, Zachary, and see whether it makes the code clearer.
History
Date User Action Args
2022-04-11 14:57:57adminsetgithub: 64609
2019-08-21 19:28:52serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg350103
2019-05-19 04:01:37BTaskayasetnosy: + BTaskaya
messages: + msg342833
2015-02-25 15:25:40serhiy.storchakasetcomponents: + Argument Clinic
2014-01-27 18:30:18zach.warecreate