[Python-checkins] cpython (merge 3.5 -> default): merge 3.5 (#24569)

benjamin.peterson python-checkins at python.org
Sun Jul 5 17:39:27 CEST 2015


https://hg.python.org/cpython/rev/75852d90c225
changeset:   96824:75852d90c225
parent:      96819:fdad98dde75a
parent:      96823:a4df0fe62b46
user:        Benjamin Peterson <benjamin at python.org>
date:        Sun Jul 05 10:38:05 2015 -0500
summary:
  merge 3.5 (#24569)

files:
  Lib/test/test_unpack_ex.py |   3 +++
  Misc/NEWS                  |  14 ++++++++++++++
  Python/ceval.c             |  15 +++++++++------
  3 files changed, 26 insertions(+), 6 deletions(-)


diff --git a/Lib/test/test_unpack_ex.py b/Lib/test/test_unpack_ex.py
--- a/Lib/test/test_unpack_ex.py
+++ b/Lib/test/test_unpack_ex.py
@@ -128,6 +128,9 @@
     ...                          for i in range(1000)) + "}"))
     1000
 
+    >>> {0:1, **{0:2}, 0:3, 0:4}
+    {0: 4}
+
 List comprehension element unpacking
 
     >>> a, b, c = [0, 1, 2], 3, 4
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,20 @@
   now can't be disabled at compile time.
 
 
+What's New in Python 3.5.0 beta 4?
+==================================
+
+*Release date: XXXX-XX-XX*
+
+Core and Builtins
+-----------------
+
+- Issue #24569: Make PEP 448 dictionary evaluation more consistent.
+
+Library
+-------
+
+
 What's New in Python 3.5.0 beta 3?
 ==================================
 
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2561,22 +2561,25 @@
         }
 
         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();
         }

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list