New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.7 regression: ast.get_docstring() for a node that lacks a docstring #78032
Comments
Python 3.7 removes an isinstance(node.body[0], Expr) check ast.get_docstring() that makes it crash when you pass in AST nodes of modules or functions that do not have docstrings. Steps to reproduce:
The failure looks like this: Traceback (most recent call last):
...
File "/home/mg/src/findimports/findimports.py", line 337, in find_imports_and_track_names
visitor.visit(root)
File "/home/mg/opt/python37/lib/python3.7/ast.py", line 262, in visit
return visitor(node)
File "/home/mg/src/findimports/findimports.py", line 169, in visitSomethingWithADocstring
self.processDocstring(ast.get_docstring(node, clean=False), lineno)
File "/home/mg/opt/python37/lib/python3.7/ast.py", line 211, in get_docstring
node = node.body[0].value
AttributeError: 'Import' object has no attribute 'value' |
mgedmin
mannequin
added
3.7 (EOL)
end of life
stdlib
Python modules in the Lib dir
type-bug
An unexpected behavior, bug, or error
labels
Jun 13, 2018
I think this fix is worth cherry-picking in 3.7.0. |
I've ran my findimports testsuite with CPython's git commit a50b825 and my tests passed, so yes. |
Fixed in 3.7.0. Thanks, everyone! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: