@@ -1664,7 +1664,8 @@ def group_to_variable_name(group: int) -> str:
1664
1664
def render_option_group_parsing (
1665
1665
self ,
1666
1666
f : Function ,
1667
- template_dict : TemplateDict
1667
+ template_dict : TemplateDict ,
1668
+ limited_capi : bool ,
1668
1669
) -> None :
1669
1670
# positional only, grouped, optional arguments!
1670
1671
# can be optional on the left or right.
@@ -1712,7 +1713,11 @@ def render_option_group_parsing(
1712
1713
count_min = sys .maxsize
1713
1714
count_max = - 1
1714
1715
1715
- add ("switch (PyTuple_GET_SIZE(args)) {\n " )
1716
+ if limited_capi :
1717
+ nargs = 'PyTuple_Size(args)'
1718
+ else :
1719
+ nargs = 'PyTuple_GET_SIZE(args)'
1720
+ add (f"switch ({ nargs } ) {{\n " )
1716
1721
for subset in permute_optional_groups (left , required , right ):
1717
1722
count = len (subset )
1718
1723
count_min = min (count_min , count )
@@ -1869,7 +1874,8 @@ def render_function(
1869
1874
template_dict ['unpack_max' ] = str (unpack_max )
1870
1875
1871
1876
if has_option_groups :
1872
- self .render_option_group_parsing (f , template_dict )
1877
+ self .render_option_group_parsing (f , template_dict ,
1878
+ limited_capi = clinic .limited_capi )
1873
1879
1874
1880
# buffers, not destination
1875
1881
for name , destination in clinic .destination_buffers .items ():
0 commit comments