[New-bugs-announce] [issue47128] Enhance Argument Clinic's NoneType return converter to give `void`

Oleg Iarygin report at bugs.python.org
Sat Mar 26 08:59:28 EDT 2022


New submission from Oleg Iarygin <oleg at arhadthedev.net>:

The attached PR makes the following possible (note that the impl has a `void` return type):

    /*[clinic input]
    _io._IOBase.writelines -> NoneType
        lines: object
        /
    [clinic start generated code]*/

    static void
    _io__IOBase_writelines_impl(PyObject *self, PyObject *lines)
    /*[clinic end generated code: output=f3feca36db72dbd1 input=286ba711cb7291ad]*/

Previously, the return type would be `Object *` with generated replacement of non-Py_None values to NULL on the other side.

So now there is no need to track whether NULL or Py_None should be returned. Or should it be Py_RETURN_NONE? Argument Clinic does it by itself returning NULL on errors and PyNone otherwise:

    static PyObject *
    _io__IOBase_writelines(PyObject *self, PyObject *lines)
    {
        PyObject *return_value = NULL;

        _io__IOBase_writelines_impl(self, lines);
        if (PyErr_Occurred()) {
            goto exit;
        }
        return_value = Py_None;
        Py_INCREF(Py_None);

    exit:
        return return_value;
    }

----------
components: Argument Clinic
messages: 416062
nosy: arhadthedev, larry
priority: normal
severity: normal
status: open
title: Enhance Argument Clinic's NoneType return converter to give `void`
type: enhancement
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47128>
_______________________________________


More information about the New-bugs-announce mailing list