gh-142579: Remove the self converter hack in winreg.c (GH-142580)

This commit is contained in:
AN Long 2025-12-12 02:06:26 +09:00 committed by GitHub
parent 8cfa351560
commit ffc7172124
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 25 deletions

12
PC/clinic/winreg.c.h generated
View file

@ -73,19 +73,13 @@ PyDoc_STRVAR(winreg_HKEYType___enter____doc__,
#define WINREG_HKEYTYPE___ENTER___METHODDEF \
{"__enter__", (PyCFunction)winreg_HKEYType___enter__, METH_NOARGS, winreg_HKEYType___enter____doc__},
static PyHKEYObject *
static PyObject *
winreg_HKEYType___enter___impl(PyHKEYObject *self);
static PyObject *
winreg_HKEYType___enter__(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
PyHKEYObject *_return_value;
_return_value = winreg_HKEYType___enter___impl((PyHKEYObject *)self);
return_value = (PyObject *)_return_value;
return return_value;
return winreg_HKEYType___enter___impl((PyHKEYObject *)self);
}
#endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)) */
@ -1842,4 +1836,4 @@ exit:
#ifndef WINREG_QUERYREFLECTIONKEY_METHODDEF
#define WINREG_QUERYREFLECTIONKEY_METHODDEF
#endif /* !defined(WINREG_QUERYREFLECTIONKEY_METHODDEF) */
/*[clinic end generated code: output=ce7e8e38884851fb input=a9049054013a1b77]*/
/*[clinic end generated code: output=97295995db2c24e9 input=a9049054013a1b77]*/

View file

@ -264,19 +264,8 @@ class HKEY_return_converter(CReturnConverter):
self.err_occurred_if_null_pointer("_return_value", data)
data.return_conversion.append(
'return_value = PyHKEY_FromHKEY(_PyModule_GetState(module), _return_value);\n')
# HACK: this only works for PyHKEYObjects, nothing else.
# Should this be generalized and enshrined in clinic.py,
# destroy this converter with prejudice.
class self_return_converter(CReturnConverter):
type = 'PyHKEYObject *'
def render(self, function, data):
self.declare(data)
data.return_conversion.append(
'return_value = (PyObject *)_return_value;\n')
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=4979f33998ffb6f8]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=b34c8217647f5fef]*/
#include "clinic/winreg.c.h"
@ -333,14 +322,14 @@ winreg_HKEYType_Detach_impl(PyHKEYObject *self)
}
/*[clinic input]
winreg.HKEYType.__enter__ -> self
winreg.HKEYType.__enter__
[clinic start generated code]*/
static PyHKEYObject *
static PyObject *
winreg_HKEYType___enter___impl(PyHKEYObject *self)
/*[clinic end generated code: output=52c34986dab28990 input=c40fab1f0690a8e2]*/
/*[clinic end generated code: output=70ec10933068a08c input=85f6abf60774c88c]*/
{
return (PyHKEYObject*)Py_XNewRef(self);
return Py_XNewRef(self);
}