Author: Raffael Tfirst <[email protected]>
Branch: py3.5-async
Changeset: r85540:1232cebac106
Date: 2016-07-04 17:52 +0200
http://bitbucket.org/pypy/pypy/changeset/1232cebac106/

Log:    (copy unpack fixes from py3.5 branch)

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1353,21 +1353,37 @@
         w_sum = self.unpack_helper(itemcount, next_instr)
         self.pushvalue(self.space.newlist(w_sum))
         
+    def getFuncDesc(func):
+        if self.space.type(aaa).name.decode('utf-8') == 'method':
+            return "()"
+        elif self.space.type(aaa).name.decode('utf-8') == 'function':
+            return "()"
+        else:
+            return " object";
+    
     def BUILD_MAP_UNPACK_WITH_CALL(self, itemcount, next_instr):
         num_maps = itemcount & 0xff
+        function_location = (itemcount>>8) & 0xff
         w_dict = self.space.newdict()
+        dict_class = w_dict.__class__
         for i in range(num_maps, 0, -1):
             w_item = self.peekvalue(i-1)
-            if not issubclass(w_item.__class__, 
self.space.newdict().__class__):
+            if not issubclass(w_item.__class__, dict_class):
                 raise oefmt(self.space.w_TypeError,
-                        "%s is not a mapping", w_item.__class__.__name__)
+                        "'%T' object is not a mapping", w_item)
             num_items = w_item.length()
+            keys = w_item.w_keys()
             for j in range(num_items):
-                (w_key, w_value) = w_item.popitem()
-                if self.space.is_true(self.space.contains(w_dict,w_key)):
+                if self.space.type(keys.getitem(j)).name.decode('utf-8') == 
'method':
+                    err_fun = self.peekvalue(num_maps + function_location-1)
                     raise oefmt(self.space.w_TypeError,
-                        "got multiple values for keyword argument %s", 
self.space.unicode_w(w_key))
-                self.space.setitem(w_dict, w_key, w_value)
+                        "%N%s keywords must be strings", err_fun, 
getFuncDesc(err_fun))
+                if 
self.space.is_true(self.space.contains(w_dict,keys.getitem(j))):
+                    err_fun = self.peekvalue(num_maps + function_location-1)
+                    err_arg = self.space.unicode_w(keys.getitem(j))
+                    raise oefmt(self.space.w_TypeError,
+                        "%N%s got multiple values for keyword argument %s", 
err_fun, getFuncDesc(err_fun), err_arg)
+            self.space.call_method(w_dict, 'update', w_item)
         while num_maps != 0:
             self.popvalue()
             num_maps -= 1
@@ -1375,15 +1391,13 @@
         
     def BUILD_MAP_UNPACK(self, itemcount, next_instr):
         w_dict = self.space.newdict()
+        dict_class = w_dict.__class__
         for i in range(itemcount, 0, -1):
             w_item = self.peekvalue(i-1)
-            if not issubclass(w_item.__class__, 
self.space.newdict().__class__):
+            if not issubclass(w_item.__class__, dict_class):
                 raise oefmt(self.space.w_TypeError,
-                        "%s is not a mapping", w_item.__class__.__name__)
-            num_items = w_item.length()
-            for j in range(num_items):
-                (w_key, w_value) = w_item.popitem()
-                self.space.setitem(w_dict, w_key, w_value)
+                        "'%T' object is not a mapping", w_item)
+            self.space.call_method(w_dict, 'update', w_item)
         while itemcount != 0:
             self.popvalue()
             itemcount -= 1
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to