diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-07-05 15:37:25 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-07-05 15:37:25 (GMT) |
commit | d5d77aac60453694445d1509b51d7514871dbff8 (patch) | |
tree | b0b3e94cffe817baff1e775e9a4ce7ef653fb571 /Python | |
parent | 1554b17856148596bbec6a22de910cdf6e20a22f (diff) | |
download | cpython-d5d77aac60453694445d1509b51d7514871dbff8.zip cpython-d5d77aac60453694445d1509b51d7514871dbff8.tar.gz cpython-d5d77aac60453694445d1509b51d7514871dbff8.tar.bz2 |
set items in dict displays from left to right (closes #24569)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index e68ae33..ac52ad9 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2561,22 +2561,25 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) } TARGET(BUILD_MAP) { + int i; PyObject *map = _PyDict_NewPresized((Py_ssize_t)oparg); if (map == NULL) goto error; - while (--oparg >= 0) { + for (i = oparg; i > 0; i--) { int err; - PyObject *value = TOP(); - PyObject *key = SECOND(); - STACKADJ(-2); + PyObject *key = PEEK(2*i); + PyObject *value = PEEK(2*i - 1); err = PyDict_SetItem(map, key, value); - Py_DECREF(value); - Py_DECREF(key); if (err != 0) { Py_DECREF(map); goto error; } } + + while (oparg--) { + Py_DECREF(POP()); + Py_DECREF(POP()); + } PUSH(map); DISPATCH(); } |