gh-139783: Fix inspect.getsourcelines() for the case when a decorator is followed by a comment or an empty line (GH-139836)

This commit is contained in:
Serhiy Storchaka 2025-10-10 10:51:24 +03:00 committed by GitHub
parent e31c22dbf9
commit f4104f5d74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 1 deletions

View file

@ -1065,7 +1065,9 @@ def __init__(self):
def tokeneater(self, type, token, srowcol, erowcol, line):
if not self.started and not self.indecorator:
if type == tokenize.INDENT or token == "async":
if type in (tokenize.INDENT, tokenize.COMMENT, tokenize.NL):
pass
elif token == "async":
pass
# skip any decorators
elif token == "@":