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
C API: Add PyLong_FileDescriptor_Converter(): make private _PyLong_FileDescriptor_Converter() public #116646
Comments
I don't think we need public API for a wrapper that adapts an existing public function to what AC needs. I don't see how this helps users. Could AC be changed to emit those few lines directly? |
Argument Clinic now calls directly PyObject_AsFileDescriptor() for the "fildes" format. Add tests on the "fildes" format in _testclinic_limited.
Argument Clinic now calls directly PyObject_AsFileDescriptor() for the "fildes" format. Add tests on the "fildes" format in _testclinic_limited.
That sounds like a great idea: I wrote PR #116736 for that. It makes the generated code compatible with the limited C API. I didn't realize that Argument Clinic was already being used in CPython internals to generate code using the private |
Add tests on the "fildes" converter in _testclinic_limited.
Add tests on the "fildes" converter to _testclinic_limited.
Add tests on the "fildes" converter to _testclinic_limited.
Fixed by d402872 |
Only add includes when the converter is effectively used.
Only add includes when the converter is effectively used.
The fildes converter of Argument Clinic now always call PyObject_AsFileDescriptor(), not only for the limited C API. The _PyLong_FileDescriptor_Converter() converter stays as a fallback when PyObject_AsFileDescriptor() cannot be used.
…thon#116769) Add tests on the "fildes" converter to _testclinic_limited.
…6793) Only add includes when the converter is effectively used.
…python#116806) The fildes converter of Argument Clinic now always call PyObject_AsFileDescriptor(), not only for the limited C API. The _PyLong_FileDescriptor_Converter() converter stays as a fallback when PyObject_AsFileDescriptor() cannot be used.
…thon#116769) Add tests on the "fildes" converter to _testclinic_limited.
…6793) Only add includes when the converter is effectively used.
…python#116806) The fildes converter of Argument Clinic now always call PyObject_AsFileDescriptor(), not only for the limited C API. The _PyLong_FileDescriptor_Converter() converter stays as a fallback when PyObject_AsFileDescriptor() cannot be used.
…thon#116769) Add tests on the "fildes" converter to _testclinic_limited.
…6793) Only add includes when the converter is effectively used.
…python#116806) The fildes converter of Argument Clinic now always call PyObject_AsFileDescriptor(), not only for the limited C API. The _PyLong_FileDescriptor_Converter() converter stays as a fallback when PyObject_AsFileDescriptor() cannot be used.
I propose to make the private
_PyLong_FileDescriptor_Converter()
function public and add it to the limited C API (version 3.13).The function is used used by 4 stdlib C extensions: posix, fcntl, select and termios. Making the function public helps to build these extensions with the limited C API.
In the PyPI top 5,000 projects (at 2023-11-15), no project uses
_PyLong_FileDescriptor_Converter()
, but 25 projects use directlyPyObject_AsFileDescriptor()
:To convert an object to a file descriptor, Argument Clinic generates code calling
_PyLong_FileDescriptor_Converter()
.This function is quite simple, it's a thin wrapper to the public
PyObject_AsFileDescriptor()
function:PyObject_AsFileDescriptor(obj)
converts Python integer to a Cint
, or callobj.fileno()
and converts the result to a Cint
, or raise aTypeError
.The API for converter callback is already exposed in
PyArg_ParseTuple()
: seeO&
format documentation: https://docs.python.org/dev/c-api/arg.html#other-objectsThere is already
PyUnicode_FSConverter()
in the limited C API.Linked PRs
The text was updated successfully, but these errors were encountered: