Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2f07a66d
Commit
2f07a66d
authored
Jul 23, 2015
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #24688: ast.get_docstring() for 'async def' functions.
parent
943ddac1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
1 deletion
+6
-1
Lib/ast.py
Lib/ast.py
+1
-1
Lib/test/test_ast.py
Lib/test/test_ast.py
+3
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/ast.py
View file @
2f07a66d
...
...
@@ -194,7 +194,7 @@ def get_docstring(node, clean=True):
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
):
...
...
Lib/test/test_ast.py
View file @
2f07a66d
...
...
@@ -511,6 +511,9 @@ class ASTHelpers_Test(unittest.TestCase):
self
.
assertEqual
(
ast
.
get_docstring
(
node
.
body
[
0
]),
'line one
\
n
line two'
)
node
=
ast
.
parse
(
'async def foo():
\
n
"""spam
\
n
ham"""'
)
self
.
assertEqual
(
ast
.
get_docstring
(
node
.
body
[
0
]),
'spam
\
n
ham'
)
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
})
...
...
Misc/NEWS
View file @
2f07a66d
...
...
@@ -53,6 +53,8 @@ Library
-
Issue
#
24669
:
Fix
inspect
.
getsource
()
for
'async def'
functions
.
Patch
by
Kai
Groner
.
-
Issue
#
24688
:
ast
.
get_docstring
()
for
'async def'
functions
.
Build
-----
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment