Skip to content

Commit fdcc3a0

Browse files
committed
Check token string first, then do the line math
1 parent b9c5baa commit fdcc3a0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/traceback.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,12 +1467,12 @@ def _find_keyword_typos(self):
14671467
for token in tokenize.generate_tokens(io.StringIO(error_code).readline):
14681468
if token.type != tokenize.NAME:
14691469
continue
1470+
if keyword.iskeyword(token.string):
1471+
continue
14701472
# Only consider NAME tokens on the same line as the error
14711473
the_end = end_line if line == 0 else end_line + 1
14721474
if token.start[0] + line != the_end:
14731475
continue
1474-
if keyword.iskeyword(token.string):
1475-
continue
14761476
rank = abs(offset - token.end[1])
14771477
heapq.heappush(tokens, (rank, token))
14781478
except Exception:

0 commit comments

Comments
 (0)