diff options
author | Jörn Heissler <joernheissler@users.noreply.github.com> | 2019-06-22 14:40:55 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-06-22 14:40:55 (GMT) |
commit | c8a35417db8853a253517a3e5190e174075c6384 (patch) | |
tree | 760e1a6590e7244315d4c8ac35acc8a0a6f6b736 /Python | |
parent | bb110cc2ed81447fb48805f31146cf31323a8fc3 (diff) | |
download | cpython-c8a35417db8853a253517a3e5190e174075c6384.zip cpython-c8a35417db8853a253517a3e5190e174075c6384.tar.gz cpython-c8a35417db8853a253517a3e5190e174075c6384.tar.bz2 |
bpo-35224: Reverse evaluation order of key: value in dict comprehensions (GH-14139)
… as proposed in PEP 572; key is now evaluated before value.
https://bugs.python.org/issue35224
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 4 | ||||
-rw-r--r-- | Python/compile.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 4ca986a..5d29d41 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2940,8 +2940,8 @@ main_loop: } case TARGET(MAP_ADD): { - PyObject *key = TOP(); - PyObject *value = SECOND(); + PyObject *value = TOP(); + PyObject *key = SECOND(); PyObject *map; int err; STACK_SHRINK(2); diff --git a/Python/compile.c b/Python/compile.c index 4d3ecfe..7bdf406 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: |