[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

@ -776,6 +776,22 @@ class TestOneliners(GetSourceBase):
# where the second line _is_ indented.
self.assertSourceEqual(mod2.tlli, 33, 34)
def test_parenthesized_multiline_lambda(self):
# Test inspect.getsource with a parenthesized multi-line lambda
# function.
self.assertSourceEqual(mod2.parenthesized_lambda, 279, 279)
self.assertSourceEqual(mod2.parenthesized_lambda2, 281, 281)
self.assertSourceEqual(mod2.parenthesized_lambda3, 283, 283)
def test_post_line_parenthesized_lambda(self):
# Test inspect.getsource with a parenthesized multi-line lambda
# function.
self.assertSourceEqual(mod2.post_line_parenthesized_lambda1, 286, 287)
def test_nested_lambda(self):
# Test inspect.getsource with a nested lambda function.
self.assertSourceEqual(mod2.nested_lambda, 291, 292)
def test_onelinefunc(self):
# Test inspect.getsource with a regular one-line function.
self.assertSourceEqual(mod2.onelinefunc, 37, 37)