mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-83035: handle decorator with nested parens in inspect.getsource (#99654)
This commit is contained in:
parent
b11a384dc7
commit
68e41295b8
4 changed files with 22 additions and 9 deletions
|
@ -1160,7 +1160,6 @@ class BlockFinder:
|
|||
self.started = False
|
||||
self.passline = False
|
||||
self.indecorator = False
|
||||
self.decoratorhasargs = False
|
||||
self.last = 1
|
||||
self.body_col0 = None
|
||||
|
||||
|
@ -1175,13 +1174,6 @@ class BlockFinder:
|
|||
self.islambda = True
|
||||
self.started = True
|
||||
self.passline = True # skip to the end of the line
|
||||
elif token == "(":
|
||||
if self.indecorator:
|
||||
self.decoratorhasargs = True
|
||||
elif token == ")":
|
||||
if self.indecorator:
|
||||
self.indecorator = False
|
||||
self.decoratorhasargs = False
|
||||
elif type == tokenize.NEWLINE:
|
||||
self.passline = False # stop skipping when a NEWLINE is seen
|
||||
self.last = srowcol[0]
|
||||
|
@ -1189,7 +1181,7 @@ class BlockFinder:
|
|||
raise EndOfBlock
|
||||
# hitting a NEWLINE when in a decorator without args
|
||||
# ends the decorator
|
||||
if self.indecorator and not self.decoratorhasargs:
|
||||
if self.indecorator:
|
||||
self.indecorator = False
|
||||
elif self.passline:
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue