mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
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:
parent
2a54c4b25e
commit
a76288ad9b
4 changed files with 74 additions and 48 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue