mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #24669: Fix inspect.getsource() for 'async def' functions.
Patch by Kai Groner.
This commit is contained in:
parent
036a71bf25
commit
e4e811d65b
4 changed files with 9 additions and 1 deletions
|
@ -798,7 +798,7 @@ def findsource(object):
|
|||
if not hasattr(object, 'co_firstlineno'):
|
||||
raise OSError('could not find function definition')
|
||||
lnum = object.co_firstlineno - 1
|
||||
pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
|
||||
pat = re.compile(r'^(\s*def\s)|(\s*async\s+def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
|
||||
while lnum > 0:
|
||||
if pat.match(lines[lnum]): break
|
||||
lnum = lnum - 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue