summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-08-29 11:33:28 (GMT)
committerGitHub <noreply@github.com>2023-08-29 11:33:28 (GMT)
commite675e515aeed16cb5091e310cb161b10c16a237d (patch)
tree48fc06f71ce4c6953de8af288e37d93a94564a9d
parent0d140b8c5ea83d095cb35b6b0c9434cb63fe6ced (diff)
downloadcpython-e675e515aeed16cb5091e310cb161b10c16a237d.zip
cpython-e675e515aeed16cb5091e310cb161b10c16a237d.tar.gz
cpython-e675e515aeed16cb5091e310cb161b10c16a237d.tar.bz2
gh-108494: Argument Clinic: fix option group for Limited C API (#108574)
Use PyTuple_Size() instead of PyTuple_GET_SIZE().
-rwxr-xr-xTools/clinic/clinic.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 2b01668..ec5bf30 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -1664,7 +1664,8 @@ class CLanguage(Language):
def render_option_group_parsing(
self,
f: Function,
- template_dict: TemplateDict
+ template_dict: TemplateDict,
+ limited_capi: bool,
) -> None:
# positional only, grouped, optional arguments!
# can be optional on the left or right.
@@ -1712,7 +1713,11 @@ class CLanguage(Language):
count_min = sys.maxsize
count_max = -1
- add("switch (PyTuple_GET_SIZE(args)) {\n")
+ if limited_capi:
+ nargs = 'PyTuple_Size(args)'
+ else:
+ nargs = 'PyTuple_GET_SIZE(args)'
+ add(f"switch ({nargs}) {{\n")
for subset in permute_optional_groups(left, required, right):
count = len(subset)
count_min = min(count_min, count)
@@ -1869,7 +1874,8 @@ class CLanguage(Language):
template_dict['unpack_max'] = str(unpack_max)
if has_option_groups:
- self.render_option_group_parsing(f, template_dict)
+ self.render_option_group_parsing(f, template_dict,
+ limited_capi=clinic.limited_capi)
# buffers, not destination
for name, destination in clinic.destination_buffers.items():