mirror of https://github.com/python/cpython
gh-92256: Improve Argument Clinic parser error messages (GH-92268)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 4bd07d1dbd
)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
7540a432ce
commit
de3349019b
|
@ -1628,10 +1628,16 @@ class BlockParser:
|
|||
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):
|
||||
return False
|
||||
if line.startswith(stop_line):
|
||||
remainder = line[len(stop_line):]
|
||||
return (not remainder) or remainder.isspace()
|
||||
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
|
||||
|
||||
# consume body of program
|
||||
while self.input:
|
||||
|
|
Loading…
Reference in New Issue