Issue #24485: Function source inspection fails on closures. · pythoncapi/cpython@f98c35a · GitHub
Skip to content

Commit f98c35a

Browse files
committed
Issue python#24485: Function source inspection fails on closures.
The fix for Issue python#21217 introduced a regression that caused `inspect.getsource` to return incorrect results on nested functions. The root cause of the regression was due to switching the implementation to analyze the underlying bytecode instead of the source code. This commit switches things back to analyzing the source code in a more complete way. The original bug and the regression are both fixed by the new source code analysis.
2 parents c6fde85 + 5b718d7 commit f98c35a

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

Lib/inspect.py

Lines changed: 22 additions & 4 deletions

Lib/test/test_inspect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ def test_replacing_decorator(self):
464464
def test_getsource_unwrap(self):
465465
self.assertSourceEqual(mod2.real, 130, 132)
466466

467-
@unittest.expectedFailure
468467
def test_decorator_with_lambda(self):
469468
self.assertSourceEqual(mod2.func114, 113, 115)
470469

Misc/NEWS

Lines changed: 7 additions & 0 deletions

0 commit comments

Comments
 (0)