Skip to content

Commit

Permalink
gh-116646, AC: Always use PyObject_AsFileDescriptor() in fildes (#116806
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
vstinner authored Mar 14, 2024
1 parent 2a54c4b commit a76288a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 48 deletions.
48 changes: 31 additions & 17 deletions Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions Modules/clinic/selectmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 17 additions & 10 deletions Modules/clinic/termios.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a76288a

Please sign in to comment.