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):
@deco_factory(foo=(1 + 2), bar=lambda: 1)
def complex_decorated(foo=0, bar=lambda: 0):
return foo + bar()
+
+# line 276
+parenthesized_lambda = (
+ lambda: ())
+parenthesized_lambda2 = [
+ lambda: ()][0]
+parenthesized_lambda3 = {0:
+ lambda: ()}[0]
+
+# line 285
+post_line_parenthesized_lambda1 = (lambda: ()
+)
+
+# line 289
+nested_lambda = (
+ lambda right: [].map(
+ lambda length: ()))
# 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)