[pypy-svn] r31330 - in pypy/dist/pypy/objspace/std: . test

mwh at codespeak.net mwh at codespeak.net
Wed Aug 16 09:30:24 CEST 2006


Author: mwh
Date: Wed Aug 16 09:30:22 2006
New Revision: 31330

Modified:
   pypy/dist/pypy/objspace/std/dictmultiobject.py
   pypy/dist/pypy/objspace/std/dictobject.py
   pypy/dist/pypy/objspace/std/dictstrobject.py
   pypy/dist/pypy/objspace/std/dicttype.py
   pypy/dist/pypy/objspace/std/test/test_dictobject.py
Log:
Revert revision 31319:
"Added keyword arguments to dict.update()."
It broke translation.


Modified: pypy/dist/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictmultiobject.py	(original)
+++ pypy/dist/pypy/objspace/std/dictmultiobject.py	Wed Aug 16 09:30:22 2006
@@ -344,11 +344,11 @@
             w_dict.implementation = w_dict.implementation.setitem(w_k, w_v)
     else:
         if space.is_true(w_src):
-            from pypy.objspace.std.dicttype import update1
-            update1(space, w_dict, w_src)
+            from pypy.objspace.std.dicttype import dict_update__ANY_ANY
+            dict_update__ANY_ANY(space, w_dict, w_src)
     if space.is_true(w_kwds):
-        from pypy.objspace.std.dicttype import update1
-        update1(space, w_dict, w_kwds)
+        from pypy.objspace.std.dicttype import dict_update__ANY_ANY
+        dict_update__ANY_ANY(space, w_dict, w_kwds)
 
 def getitem__DictMulti_ANY(space, w_dict, w_lookup):
     try:
@@ -434,9 +434,9 @@
     return w_res
 
 def dict_copy__DictMulti(space, w_self):
-    from pypy.objspace.std.dicttype import update1
+    from pypy.objspace.std.dicttype import dict_update__ANY_ANY
     w_new = W_DictMultiObject(space)
-    update1(space, w_new, w_self)
+    dict_update__ANY_ANY(space, w_new, w_self)
     return w_new
 
 def dict_items__DictMulti(space, w_self):

Modified: pypy/dist/pypy/objspace/std/dictobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictobject.py	(original)
+++ pypy/dist/pypy/objspace/std/dictobject.py	Wed Aug 16 09:30:22 2006
@@ -65,11 +65,11 @@
             w_dict.content[w_k] = w_v
     else:
         if space.is_true(w_src):
-            from pypy.objspace.std.dicttype import update1
-            update1(space, w_dict, w_src)
+            from pypy.objspace.std.dicttype import dict_update__ANY_ANY
+            dict_update__ANY_ANY(space, w_dict, w_src)
     if space.is_true(w_kwds):
-        from pypy.objspace.std.dicttype import update1
-        update1(space, w_dict, w_kwds)
+        from pypy.objspace.std.dicttype import dict_update__ANY_ANY
+        dict_update__ANY_ANY(space, w_dict, w_kwds)
 
 def getitem__Dict_ANY(space, w_dict, w_lookup):
     try:

Modified: pypy/dist/pypy/objspace/std/dictstrobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictstrobject.py	(original)
+++ pypy/dist/pypy/objspace/std/dictstrobject.py	Wed Aug 16 09:30:22 2006
@@ -121,11 +121,11 @@
             w_dict.setitem(w_k, w_v)
     else:
         if space.is_true(w_src):
-            from pypy.objspace.std.dicttype import update1
-            update1(space, w_dict, w_src)
+            from pypy.objspace.std.dicttype import dict_update__ANY_ANY
+            dict_update__ANY_ANY(space, w_dict, w_src)
     if space.is_true(w_kwds):
-        from pypy.objspace.std.dicttype import update1
-        update1(space, w_dict, w_kwds)
+        from pypy.objspace.std.dicttype import dict_update__ANY_ANY
+        dict_update__ANY_ANY(space, w_dict, w_kwds)
 
 def getitem__DictStr_ANY(space, w_dict, w_lookup):
     try:

Modified: pypy/dist/pypy/objspace/std/dicttype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dicttype.py	(original)
+++ pypy/dist/pypy/objspace/std/dicttype.py	Wed Aug 16 09:30:22 2006
@@ -30,7 +30,7 @@
 dict_setdefault = SMM('setdefault',    3, defaults=(None,),
                       doc='D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d'
                           ' if k not in D')
-dict_update     = SMM('update',        1, general__args__=True,
+dict_update     = SMM('update',        2, defaults=((),),
                       doc='D.update(E, **F) -> None.  Update D from E and F:'
                           ' for k in E: D[k] = E[k]\n(if E has keys else: for'
                           ' (k, v) in E: D[k] = v) then: for k in F: D[k] ='
@@ -55,7 +55,7 @@
 # gateway is imported in the stdtypedef module
 app = gateway.applevel('''
 
-    def update1(d, o):
+    def update(d, o):
         if hasattr(o, 'keys'):
             for k in o.keys():
                 d[k] = o[k]
@@ -63,14 +63,6 @@
             for k,v in o:
                 d[k] = v
 
-    def update(d, *args, **kwargs):
-        if len(args) == 1:
-            update1(d, args[0])
-        elif len(args) > 1:
-            raise TypeError("update takes at most 1 (non-keyword) argument")
-        if kwargs:
-            update1(d, kwargs)
-
     def popitem(d):
         k = d.keys()
         if not k:
@@ -118,7 +110,7 @@
 ''', filename=__file__)
 #XXX what about dict.fromkeys()?
 
-dict_update__ANY             = app.interphook("update")
+dict_update__ANY_ANY         = app.interphook("update")
 dict_popitem__ANY            = app.interphook("popitem")
 dict_get__ANY_ANY_ANY        = app.interphook("get")
 dict_setdefault__ANY_ANY_ANY = app.interphook("setdefault")
@@ -126,7 +118,6 @@
 dict_iteritems__ANY          = app.interphook("iteritems")
 dict_iterkeys__ANY           = app.interphook("iterkeys")
 dict_itervalues__ANY         = app.interphook("itervalues")
-update1                      = app.interphook("update1")
 
 register_all(vars(), globals())
 

Modified: pypy/dist/pypy/objspace/std/test/test_dictobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_dictobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_dictobject.py	Wed Aug 16 09:30:22 2006
@@ -245,17 +245,7 @@
         d = {}
         d.update()
         assert d == {}
-
-    def test_update_kwargs(self):
-        d = {}
-        d.update(foo='bar', baz=1)
-        assert d == {'foo': 'bar', 'baz': 1}
-
-    def test_update_dict_and_kwargs(self):
-        d = {}
-        d.update({'foo': 'bar'}, baz=1)
-        assert d == {'foo': 'bar', 'baz': 1}
-
+    
     def test_values(self):
         d = {1:2, 3:4}
         vals = d.values()



More information about the Pypy-commit mailing list