This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 3.7 regression: ast.get_docstring() for a node that lacks a docstring
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ned.deily Nosy List: methane, mgedmin, miss-islington, ned.deily, serhiy.storchaka
Priority: Keywords: patch

Created on 2018-06-13 11:25 by mgedmin, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7682 merged serhiy.storchaka, 2018-06-13 12:14
PR 7701 merged miss-islington, 2018-06-15 08:05
Messages (8)
msg319453 - (view) Author: Marius Gedminas (mgedmin) * Date: 2018-06-13 11:25
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:

- git clone https://github.com/mgedmin/findimports
- cd findimports
- tox -e py37

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'
msg319455 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-13 12:15
I think this fix is worth cherry-picking in 3.7.0.
msg319592 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-15 08:05
New changeset 08f127a3cad8ce4eb281d30d9488c91b0fd7cfed by Serhiy Storchaka in branch 'master':
bpo-33851: Fix ast.get_docstring() for a node that lacks a docstring. (GH-7682)
https://github.com/python/cpython/commit/08f127a3cad8ce4eb281d30d9488c91b0fd7cfed
msg319595 - (view) Author: miss-islington (miss-islington) Date: 2018-06-15 08:25
New changeset a50b825c18a92655f3dd7939e793fa3d4440d886 by Miss Islington (bot) in branch '3.7':
bpo-33851: Fix ast.get_docstring() for a node that lacks a docstring. (GH-7682)
https://github.com/python/cpython/commit/a50b825c18a92655f3dd7939e793fa3d4440d886
msg320339 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-06-23 23:42
@mgedmin, Just to be certain, are you able to verify that the change in PR 7701 fixes the problem you see with 3.7.0rc1?
msg320419 - (view) Author: Marius Gedminas (mgedmin) * Date: 2018-06-25 12:25
I've ran my findimports testsuite with CPython's git commit a50b825c18a92655f3dd7939e793fa3d4440d886 and my tests passed, so yes.
msg320632 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-06-27 22:34
New changeset 235d0fb93cb456701ce24fad2bc307e9f0312d73 by Ned Deily (Miss Islington (bot)) in branch '3.7':
bpo-33851: Fix ast.get_docstring() for a node that lacks a docstring. (GH-7682)
https://github.com/python/cpython/commit/235d0fb93cb456701ce24fad2bc307e9f0312d73
msg320640 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-06-28 01:29
Fixed in 3.7.0.  Thanks, everyone!
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 78032
2018-06-28 01:29:04ned.deilysetstatus: open -> closed
priority: release blocker ->
messages: + msg320640

resolution: fixed
stage: patch review -> resolved
2018-06-27 22:34:50ned.deilysetmessages: + msg320632
2018-06-25 12:25:23mgedminsetmessages: + msg320419
2018-06-23 23:42:09ned.deilysetmessages: + msg320339
2018-06-15 08:25:21miss-islingtonsetnosy: + miss-islington
messages: + msg319595
2018-06-15 08:24:33serhiy.storchakasetassignee: ned.deily
2018-06-15 08:05:38miss-islingtonsetpull_requests: + pull_request7317
2018-06-15 08:05:18serhiy.storchakasetmessages: + msg319592
2018-06-13 12:16:12serhiy.storchakasetnosy: + methane
2018-06-13 12:15:50serhiy.storchakasetpriority: normal -> release blocker
versions: + Python 3.8
nosy: + serhiy.storchaka, ned.deily

messages: + msg319455
2018-06-13 12:14:29serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request7294
2018-06-13 11:25:47mgedmincreate