-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Description
Bug report
Bug description:
There is an Argument Clinic converter (marked as “HACK” in the comment) in winreg.c:
Lines 268 to 277 in a275385
| # 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') |
It is only used in the HKEY.__enter__ method. In that method, the type of the return value PyObject * is cast to a PyHKEYObject *:
Lines 335 to 344 in a275385
| /*[clinic input] | |
| winreg.HKEYType.__enter__ -> self | |
| [clinic start generated code]*/ | |
| static PyHKEYObject * | |
| winreg_HKEYType___enter___impl(PyHKEYObject *self) | |
| /*[clinic end generated code: output=52c34986dab28990 input=c40fab1f0690a8e2]*/ | |
| { | |
| return (PyHKEYObject*)Py_XNewRef(self); | |
| } |
What the self_return_converter does is simply cast the PyHKEYObject * back to PyObject *, which is unnecessary.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows