changeset: 97013:5c8c88973709 parent: 97011:6c6f1e107cfe parent: 97012:ecb13b9c4cd0 user: Yury Selivanov date: Thu Jul 23 08:55:07 2015 +0300 files: Misc/NEWS description: Merge 3.5 (Issue #24688) diff -r 6c6f1e107cfe -r 5c8c88973709 Lib/ast.py --- a/Lib/ast.py Thu Jul 23 08:09:05 2015 +1200 +++ b/Lib/ast.py Thu Jul 23 08:55:07 2015 +0300 @@ -194,7 +194,7 @@ be found. If the node provided does not have docstrings a TypeError will be raised. """ - if not isinstance(node, (FunctionDef, ClassDef, Module)): + if not isinstance(node, (AsyncFunctionDef, FunctionDef, ClassDef, Module)): raise TypeError("%r can't have docstrings" % node.__class__.__name__) if node.body and isinstance(node.body[0], Expr) and \ isinstance(node.body[0].value, Str): diff -r 6c6f1e107cfe -r 5c8c88973709 Lib/test/test_ast.py --- a/Lib/test/test_ast.py Thu Jul 23 08:09:05 2015 +1200 +++ b/Lib/test/test_ast.py Thu Jul 23 08:55:07 2015 +0300 @@ -511,6 +511,9 @@ self.assertEqual(ast.get_docstring(node.body[0]), 'line one\nline two') + node = ast.parse('async def foo():\n """spam\n ham"""') + self.assertEqual(ast.get_docstring(node.body[0]), 'spam\nham') + def test_literal_eval(self): self.assertEqual(ast.literal_eval('[1, 2, 3]'), [1, 2, 3]) self.assertEqual(ast.literal_eval('{"foo": 42}'), {"foo": 42}) diff -r 6c6f1e107cfe -r 5c8c88973709 Misc/NEWS --- a/Misc/NEWS Thu Jul 23 08:09:05 2015 +1200 +++ b/Misc/NEWS Thu Jul 23 08:55:07 2015 +0300 @@ -76,6 +76,8 @@ - Issue #24669: Fix inspect.getsource() for 'async def' functions. Patch by Kai Groner. +- Issue #24688: ast.get_docstring() for 'async def' functions. + Build -----