STINNER Victor <[email protected]> added the comment:
If the file content changed, I'm not sure that the folloing heuristic will
always find the expected function:
lnum = object.co_firstlineno - 1
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
return lines, lnum
The regex doesn't search for the function name.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37166>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com