mirror of
https://github.com/python/cpython.git
synced 2025-09-05 16:31:16 +00:00
bpo-39220: Do not optimise annotation if 'from __future__ import annotations' is used (GH-17866)
Do not apply AST-based optimizations if 'from __future__ import annotations' is used in order to prevent information lost in the final version of the annotations.
This commit is contained in:
parent
8849e5962b
commit
d112c600ab
5 changed files with 67 additions and 40 deletions
|
@ -354,7 +354,11 @@ PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
|
|||
c.c_nestlevel = 0;
|
||||
c.c_do_not_emit_bytecode = 0;
|
||||
|
||||
if (!_PyAST_Optimize(mod, arena, c.c_optimize)) {
|
||||
_PyASTOptimizeState state;
|
||||
state.optimize = c.c_optimize;
|
||||
state.ff_features = merged;
|
||||
|
||||
if (!_PyAST_Optimize(mod, arena, &state)) {
|
||||
goto finally;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue