summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-14 09:28:58 (GMT)
committerGitHub <noreply@github.com>2024-03-14 09:28:58 (GMT)
commitd4028724f2c8c674202615b772913765423c69fd (patch)
treebb85d9e391bbcf68a21e4a7008712467a4d22f90 /Tools
parenta18c9854e8c255981f07c0a1c1503253f85b7540 (diff)
downloadcpython-d4028724f2c8c674202615b772913765423c69fd.zip
cpython-d4028724f2c8c674202615b772913765423c69fd.tar.gz
cpython-d4028724f2c8c674202615b772913765423c69fd.tar.bz2
gh-116646: Add limited C API support to AC fildes converter (#116769)
Add tests on the "fildes" converter to _testclinic_limited.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/clinic/clinic.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 4c7c4dc..c81af5e 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -3800,18 +3800,19 @@ class fildes_converter(CConverter):
type = 'int'
converter = '_PyLong_FileDescriptor_Converter'
- def converter_init(self, *, accept: TypeSet = {int, NoneType}) -> None:
- self.add_include('pycore_fileutils.h',
- '_PyLong_FileDescriptor_Converter()')
-
- def _parse_arg(self, argname: str, displayname: str) -> str | None:
- return self.format_code("""
- {paramname} = PyObject_AsFileDescriptor({argname});
- if ({paramname} == -1) {{{{
- goto exit;
- }}}}
- """,
- argname=argname)
+ 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:
+ self.add_include('pycore_fileutils.h',
+ '_PyLong_FileDescriptor_Converter()')
+ return super().parse_arg(argname, displayname, limited_capi=limited_capi)
class float_converter(CConverter):