changeset: 96977:f02c5bf59fbb branch: 3.5 parent: 96974:65959b843666 user: Yury Selivanov date: Tue Jul 21 19:01:52 2015 +0300 files: Lib/inspect.py Lib/test/inspect_fodder.py Lib/test/test_inspect.py Misc/NEWS description: Issue #24669: Fix inspect.getsource() for 'async def' functions. Patch by Kai Groner. diff -r 65959b843666 -r f02c5bf59fbb Lib/inspect.py --- a/Lib/inspect.py Tue Jul 21 09:29:48 2015 +0300 +++ b/Lib/inspect.py Tue Jul 21 19:01:52 2015 +0300 @@ -798,7 +798,7 @@ 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)|(.*(? 0: if pat.match(lines[lnum]): break lnum = lnum - 1 diff -r 65959b843666 -r f02c5bf59fbb Lib/test/inspect_fodder.py --- a/Lib/test/inspect_fodder.py Tue Jul 21 09:29:48 2015 +0300 +++ b/Lib/test/inspect_fodder.py Tue Jul 21 19:01:52 2015 +0300 @@ -66,3 +66,6 @@ pass def contradiction(self): pass + +async def lobbest(grenade): + pass diff -r 65959b843666 -r f02c5bf59fbb Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Tue Jul 21 09:29:48 2015 +0300 +++ b/Lib/test/test_inspect.py Tue Jul 21 19:01:52 2015 +0300 @@ -336,6 +336,7 @@ def test_getfunctions(self): functions = inspect.getmembers(mod, inspect.isfunction) self.assertEqual(functions, [('eggs', mod.eggs), + ('lobbest', mod.lobbest), ('spam', mod.spam)]) @unittest.skipIf(sys.flags.optimize >= 2, @@ -393,6 +394,7 @@ def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) self.assertSourceEqual(mod.StupidGit, 21, 50) + self.assertSourceEqual(mod.lobbest, 70, 71) def test_getsourcefile(self): self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile) diff -r 65959b843666 -r f02c5bf59fbb Misc/NEWS --- a/Misc/NEWS Tue Jul 21 09:29:48 2015 +0300 +++ b/Misc/NEWS Tue Jul 21 19:01:52 2015 +0300 @@ -45,6 +45,9 @@ - Issue #15014: SMTP.auth() and SMTP.login() now support RFC 4954's optional initial-response argument to the SMTP AUTH command. +- Issue #24669: Fix inspect.getsource() for 'async def' functions. + Patch by Kai Groner. + What's New in Python 3.5.0 beta 3? ==================================