Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-47128: Enhance Argument Clinic's NoneType return converter to give void #32126

Closed

Conversation

arhadthedev
Copy link
Member

@arhadthedev arhadthedev commented Mar 26, 2022

This 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 * and a caller would replace non-Py_None values with NULL.

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 Py_None 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;
}

https://bugs.python.org/issue47128

@arhadthedev
Copy link
Member Author

Tests / Check if generated files are up to date fails with the following report.

make regen-deepfreeze
make[1]: Entering directory '/home/runner/work/cpython/cpython'
./_bootstrap_python ./Programs/_freeze_module.py abc ./Lib/abc.py Python/frozen_modules/abc.h
make[1]: execvp: ./_bootstrap_python: Permission denied
make[1]: *** [Makefile:1194: Python/frozen_modules/abc.h] Error 127
make[1]: Leaving directory '/home/runner/work/cpython/cpython'
make: *** [Makefile:1313: regen-global-objects] Error 2
make: *** Waiting for unfinished jobs....

All other checks pass. Reopening the PR to retrigger the checks.

@arhadthedev arhadthedev reopened this Mar 26, 2022
@arhadthedev arhadthedev marked this pull request as ready for review March 26, 2022 13:56
@arhadthedev
Copy link
Member Author

The feature calls GIL-taking PyErr_Occurred. So I close the PR until GIL is removed so performance penalty decreases.

@arhadthedev
Copy link
Member Author

arhadthedev commented Jul 20, 2022

GH-95019 fully removed the NoneType return converter. As a result, this PR has no sense to be reopened anymore.

@arhadthedev arhadthedev deleted the argument-clinic-nonetype-converter branch July 20, 2022 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants