Skip to content

gh-104146: Purge dead code from Argument Clinic #104680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2023
Merged
Changes from 1 commit
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
11 changes: 1 addition & 10 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,6 @@ def permute_optional_groups(left, required, right):
If required is empty, left must also be empty.
"""
required = tuple(required)
result = []

if not required:
if left:
raise ValueError("required is empty but left is not")
Expand Down Expand Up @@ -1338,7 +1336,6 @@ def render_option_group_parsing(self, f, template_dict):
if isinstance(parameters[0].converter, self_converter):
del parameters[0]

groups = []
group = None
left = []
right = []
Expand Down Expand Up @@ -1428,8 +1425,6 @@ def render_function(self, clinic, f):
first_optional = len(selfless)
positional = selfless and selfless[-1].is_positional_only()
new_or_init = f.kind in (METHOD_NEW, METHOD_INIT)
default_return_converter = (not f.return_converter or
f.return_converter.type == 'PyObject *')
has_option_groups = False

# offset i by -1 because first_optional needs to ignore self
Expand Down Expand Up @@ -1526,7 +1521,6 @@ def render_function(self, clinic, f):
template_dict['return_value'] = data.return_value

# used by unpack tuple code generator
ignore_self = -1 if isinstance(converters[0], self_converter) else 0
unpack_min = first_optional
unpack_max = len(selfless)
template_dict['unpack_min'] = str(unpack_min)
Expand Down Expand Up @@ -1803,10 +1797,8 @@ def is_stop_line(line):
if self.verify:
if 'input' in d:
checksum = d['output']
input_checksum = d['input']
else:
checksum = d['checksum']
input_checksum = None

computed = compute_checksum(output, len(checksum))
if checksum != computed:
Expand Down Expand Up @@ -4245,8 +4237,7 @@ def directive_version(self, required):
fail("Insufficient Clinic version!\n Version: " + version + "\n Required: " + required)

def directive_module(self, name):
fields = name.split('.')
new = fields.pop()
fields = name.split('.')[1:]
Copy link
Member

Choose a reason for hiding this comment

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

pop() removes the last item in the list, no?

Suggested change
fields = name.split('.')[1:]
fields = name.split('.')[:-1]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Yes, [1:] is definitely wrong. Strangely, make clinic does not complain or generate incorrect.

module, cls = self.clinic._module_and_class(fields)
if cls:
fail("Can't nest a module inside a class!")
Expand Down