[3.12] gh-105013: Fix inspect.getsource with parenthesized multiline lambdas (GH-105021) (#105032)

gh-105013: Fix inspect.getsource with parenthesized multiline lambdas (GH-105021)
(cherry picked from commit 3a5be878be)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-05-28 04:18:43 -07:00 committed by GitHub
parent 36a4227859
commit 41b622b1e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 0 deletions

View file

@ -1242,6 +1242,14 @@ def getblock(lines):
blockfinder.tokeneater(*_token)
except (EndOfBlock, IndentationError):
pass
except SyntaxError as e:
if "unmatched" not in e.msg:
raise e from None
_, *_token_info = _token
try:
blockfinder.tokeneater(tokenize.NEWLINE, *_token_info)
except (EndOfBlock, IndentationError):
pass
return lines[:blockfinder.last]
def getsourcelines(object):