gh-116646, AC: Always use PyObject_AsFileDescriptor() in fildes (#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.
This commit is contained in:
Victor Stinner 2024-03-14 14:58:07 +01:00 committed by GitHub
parent 2a54c4b25e
commit a76288ad9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 74 additions and 48 deletions

View file

@ -3832,16 +3832,13 @@ def use_converter(self) -> None:
'_PyLong_FileDescriptor_Converter()')
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None:
if limited_capi:
return self.format_code("""
{paramname} = PyObject_AsFileDescriptor({argname});
if ({paramname} < 0) {{{{
goto exit;
}}}}
""",
argname=argname)
else:
return super().parse_arg(argname, displayname, limited_capi=limited_capi)
return self.format_code("""
{paramname} = PyObject_AsFileDescriptor({argname});
if ({paramname} < 0) {{{{
goto exit;
}}}}
""",
argname=argname)
class float_converter(CConverter):