mirror of
https://github.com/python/cpython.git
synced 2025-11-29 22:41:59 +00:00
gh-137078: Fix keyword typo recognition when executed over files (#137079)
This commit is contained in:
parent
dc53a3e52a
commit
4e08a9f97a
6 changed files with 56 additions and 7 deletions
|
|
@ -1322,7 +1322,6 @@ class TracebackException:
|
|||
lines = source.splitlines()
|
||||
|
||||
error_code = lines[line -1 if line > 0 else 0:end_line]
|
||||
error_code[0] = error_code[0][offset:]
|
||||
error_code = textwrap.dedent('\n'.join(error_code))
|
||||
|
||||
# Do not continue if the source is too large
|
||||
|
|
@ -1338,7 +1337,8 @@ class TracebackException:
|
|||
if token.type != tokenize.NAME:
|
||||
continue
|
||||
# Only consider NAME tokens on the same line as the error
|
||||
if from_filename and token.start[0]+line != end_line+1:
|
||||
the_end = end_line if line == 0 else end_line + 1
|
||||
if from_filename and token.start[0]+line != the_end:
|
||||
continue
|
||||
wrong_name = token.string
|
||||
if wrong_name in keyword.kwlist:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue