Title: Argument Clinic: add 'self' return converter
Type: enhancement Stage: needs patch
Components: Argument Clinic Versions: Python 3.5
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 2019-08-21 19:28 by serhiy.storchaka.

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 (BTaskaya) * Date: 2019-05-19 04:01
Doesn't clinic have a `self_converter` class?
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.
Date User Action Args
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