Matthias Bussonnier <bussonniermatth...@gmail.com> added the comment:
Ćukasz Langa wrote: > Inadasan, I think what we should do is to amend `ast.parse()` and `compile()` > docs that mode="exec" treats given code as a module, we should even give the > docstring handling as an example. That is what I proposed in https://bugs.python.org/issue33477 and in PR https://github.com/python/cpython/pull/6973 The other surprise, is that even is I knew AST were change and had a docstring field I was not expecting `compile()` to be affected. I think that the change for ast to have a docstring field is a good one from an API point of view for ast nodes. But It should probably be opt-in, at least with a deprecation period to make it the default. The other issue is that as it affect only sequence of statement where the first node is (was) a string, it can lead to really subtle difference in execution. MinRk said: > The only affected case for us is interactively typed string literals in > single statement cells not displaying themselves as results It might affect our downstream consumers that have syntax/ast transformation like sage, sympy on top of IPython. I doubt we have any but it's a possibility. While I would prefer (B) as well, I see how the new behavior can be useful in some case, and strongly also support the addition of a `multiline` mode, which correspond to what 3.6 and before were doing with `exec`. The other possibility is to leave `exec` and `ast.parse` with 3.6 behavior, and include a `'module'` mode that does reflect current 3.7 behavior. ---------- nosy: +mbussonn _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32911> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com