Message317683
Ł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. |
|
Date |
User |
Action |
Args |
2018-05-25 15:45:50 | mbussonn | set | recipients:
+ mbussonn, georg.brandl, rhettinger, ncoghlan, vstinner, benjamin.peterson, ned.deily, methane, lukasz.langa, Mark.Shannon, serhiy.storchaka, eitan.adler, minrk, flherne |
2018-05-25 15:45:50 | mbussonn | set | messageid: <1527263150.35.0.682650639539.issue32911@psf.upfronthosting.co.za> |
2018-05-25 15:45:50 | mbussonn | link | issue32911 messages |
2018-05-25 15:45:50 | mbussonn | create | |
|