From c8a35417db8853a253517a3e5190e174075c6384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Heissler?= Date: Sat, 22 Jun 2019 16:40:55 +0200 Subject: bpo-35224: Reverse evaluation order of key: value in dict comprehensions (GH-14139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … as proposed in PEP 572; key is now evaluated before value. https://bugs.python.org/issue35224 --- Python/compile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Python/compile.c') diff --git a/Python/compile.c b/Python/compile.c index 4d3ecfe5d6..7bdf406079 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4238,10 +4238,10 @@ compiler_sync_comprehension_generator(struct compiler *c, ADDOP_I(c, SET_ADD, gen_index + 1); break; case COMP_DICTCOMP: - /* With 'd[k] = v', v is evaluated before k, so we do + /* With '{k: v}', k is evaluated before v, so we do the same. */ - VISIT(c, expr, val); VISIT(c, expr, elt); + VISIT(c, expr, val); ADDOP_I(c, MAP_ADD, gen_index + 1); break; default: @@ -4327,10 +4327,10 @@ compiler_async_comprehension_generator(struct compiler *c, ADDOP_I(c, SET_ADD, gen_index + 1); break; case COMP_DICTCOMP: - /* With 'd[k] = v', v is evaluated before k, so we do + /* With '{k: v}', k is evaluated before v, so we do the same. */ - VISIT(c, expr, val); VISIT(c, expr, elt); + VISIT(c, expr, val); ADDOP_I(c, MAP_ADD, gen_index + 1); break; default: -- cgit v1.2.1