[issue32911] Doc strings no longer stored in body of AST

INADA Naoki report at bugs.python.org
Fri May 25 13:10:57 EDT 2018


INADA Naoki <songofacandy at gmail.com> added the comment:

> B. Revert the feature now for 3.7.0, retargeting for 3.8, and produce a 3.7.0b5 on a somewhat shorter cycle to allow downstream users to adapt to the removal.

Please note that it can't be reverted simply.
The change was introduced to ease AST-layer optimization (`"abc" + "def"` is not docstring, but `"abcdef"` is docstring.)
And we implemented some AST-layer optimization already.

There are two ways to revert the change:

B1. Just remove `.docstring` attribute and implement hack to distinguish string and docstring in some places.

B2. Remove `.docstring` attribute, but introduce `DocString` statement.  This was my patch (PR-5927)

In case of B2, thirdparty libraries should follow the change anyway.
In case of IPython, `DocString(s="spam")` may be replaced with `Expr(Str(s="spam"))`

In case of B1, I hadn't tried it yet and I don't know how difficult it is.  I'll try but I can't say estimated time for now.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32911>
_______________________________________


More information about the Python-bugs-list mailing list