Skip to content
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

gh-92256: Improve Argument Clinic parser error messages #92268

Merged
merged 7 commits into from
May 10, 2022
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 Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1628,10 +1628,16 @@ def parse_clinic_block(self, dsl_name):
def is_stop_line(line):
# make sure to recognize stop line even if it
# doesn't end with EOL (it could be the very end of the file)
if not line.startswith(stop_line):
if line.startswith(stop_line):
remainder = line[len(stop_line):]
if remainder and not remainder.isspace():
fail(f"Garbage after stop line: {remainder!r}")
return True
else:
# gh-92256: don't allow incorrectly formatted stop lines
if line.lstrip().startswith(stop_line):
fail(f"Whitespace is not allowed before the stop line: {line!r}")
return False
remainder = line[len(stop_line):]
return (not remainder) or remainder.isspace()

# consume body of program
while self.input:
Expand Down