Skip to content
Closed
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
10 changes: 8 additions & 2 deletions Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ def __init__(self):
self.passline = False
self.indecorator = False
self.decoratorhasargs = False
self.nestedparens = 0
self.last = 1

def tokeneater(self, type, token, srowcol, erowcol, line):
Expand All @@ -941,10 +942,15 @@ def tokeneater(self, type, token, srowcol, erowcol, line):
elif token == "(":
if self.indecorator:
self.decoratorhasargs = True
self.nestedparens += 1
elif token == ")":
if self.indecorator:
self.indecorator = False
self.decoratorhasargs = False
self.nestedparens -= 1
if self.nestedparens == 0:
self.indecorator = False
self.decoratorhasargs = False
else:
assert self.nestedparens > 0, self.nestedparens
elif type == tokenize.NEWLINE:
self.passline = False # stop skipping when a NEWLINE is seen
self.last = srowcol[0]
Expand Down