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

Created on 2018-06-13 11:25 by mgedmin, last changed 2018-06-15 08:25 by miss-islington.

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 (4)
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
History
Date User Action Args
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: + inada.naoki
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