]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-142579: Remove the self converter hack in winreg.c (GH-142580)
authorAN Long <aisk@users.noreply.github.com>
Thu, 11 Dec 2025 17:06:26 +0000 (02:06 +0900)
committerGitHub <noreply@github.com>
Thu, 11 Dec 2025 17:06:26 +0000 (18:06 +0100)
PC/clinic/winreg.c.h
PC/winreg.c

index d76a8d8aef8cb8bd6dff77ed86cd8d638aa37108..92cf6e8a9be187614842e5f12a4198d09d486822 100644 (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]*/
index bcb02b1229905571e5f4342aff9dc38f15b1297e..26bcd259efd9879bc4a1a2a039b7c5c28272e50c 100644 (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);
 }