summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-05-27 23:20:42 (GMT)
committerGitHub <noreply@github.com>2023-05-27 23:20:42 (GMT)
commit3a5be878be6f89ee98d0ef9a1274e6a9d9ccbc37 (patch)
treec67e713a6e1784ec67f23396d68c7e0ccd794294 /Lib/inspect.py
parentb225c08de889d2bf070e6c981c5f386cf06d961c (diff)
downloadcpython-3a5be878be6f89ee98d0ef9a1274e6a9d9ccbc37.zip
cpython-3a5be878be6f89ee98d0ef9a1274e6a9d9ccbc37.tar.gz
cpython-3a5be878be6f89ee98d0ef9a1274e6a9d9ccbc37.tar.bz2
gh-105013: Fix inspect.getsource with parenthesized multiline lambdas (#105021)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 7709a95..55530fc 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -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):