@@ -1664,7 +1664,8 @@ def group_to_variable_name(group: int) -> str:
16641664 def render_option_group_parsing (
16651665 self ,
16661666 f : Function ,
1667- template_dict : TemplateDict
1667+ template_dict : TemplateDict ,
1668+ limited_capi : bool ,
16681669 ) -> None :
16691670 # positional only, grouped, optional arguments!
16701671 # can be optional on the left or right.
@@ -1712,7 +1713,11 @@ def render_option_group_parsing(
17121713 count_min = sys .maxsize
17131714 count_max = - 1
17141715
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 " )
17161721 for subset in permute_optional_groups (left , required , right ):
17171722 count = len (subset )
17181723 count_min = min (count_min , count )
@@ -1869,7 +1874,8 @@ def render_function(
18691874 template_dict ['unpack_max' ] = str (unpack_max )
18701875
18711876 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 )
18731879
18741880 # buffers, not destination
18751881 for name , destination in clinic .destination_buffers .items ():
0 commit comments