summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-03-18 23:02:09 (GMT)
committerGitHub <noreply@github.com>2020-03-18 23:02:09 (GMT)
commitd112c600ab3f5e2910345bcc4bfc39439917ed87 (patch)
tree1b260548a6f6b9bebcbf9be74bcfb3f3f8a39068 /Python/compile.c
parent8849e5962ba481d5d414b3467a256aba2134b4da (diff)
downloadcpython-d112c600ab3f5e2910345bcc4bfc39439917ed87.zip
cpython-d112c600ab3f5e2910345bcc4bfc39439917ed87.tar.gz
cpython-d112c600ab3f5e2910345bcc4bfc39439917ed87.tar.bz2
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.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 486b7bb..a8ab873 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -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;
}