From d112c600ab3f5e2910345bcc4bfc39439917ed87 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Wed, 18 Mar 2020 23:02:09 +0000 Subject: 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. --- Python/compile.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Python/compile.c') diff --git a/Python/compile.c b/Python/compile.c index 486b7bbc01..a8ab873f31 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; } -- cgit v1.2.1