Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions 12 Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,8 @@ def group_to_variable_name(group: int) -> str:
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.
Expand Down Expand Up @@ -1713,7 +1714,11 @@ def render_option_group_parsing(
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")
Comment on lines +1718 to +1721

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style suggestion -- because of the f-strings needing the duplication of {, perhaps just being explicit in both cases would be worth it?

Suggested change
nargs = 'PyTuple_Size(args)'
else:
nargs = 'PyTuple_GET_SIZE(args)'
add(f"switch ({nargs}) {{\n")
add("switch (PyTuple_Size(args)) {\n")
else:
add("switch (PyTuple_GET_SIZE(args)) {\n")

for subset in permute_optional_groups(left, required, right):
count = len(subset)
count_min = min(count_min, count)
Expand Down Expand Up @@ -1870,7 +1875,8 @@ def render_function(
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():
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.