Bug report
Bug description:
There is an Argument Clinic converter (marked as “HACK” in the comment) in winreg.c:
|
# 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 *:
|
/*[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
Linked PRs
Bug report
Bug description:
There is an Argument Clinic converter (marked as “HACK” in the comment) in
winreg.c:cpython/PC/winreg.c
Lines 268 to 277 in a275385
It is only used in the
HKEY.__enter__method. In that method, the type of the return valuePyObject *is cast to aPyHKEYObject *:cpython/PC/winreg.c
Lines 335 to 344 in a275385
What the
self_return_converterdoes is simply cast thePyHKEYObject *back toPyObject *, which is unnecessary.CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs