[pypy-svn] r37809 - in pypy/dist/pypy: module/marshal/test objspace/std

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Feb 2 15:25:14 CET 2007


Author: cfbolz
Date: Fri Feb  2 15:25:12 2007
New Revision: 37809

Modified:
   pypy/dist/pypy/module/marshal/test/test_marshal.py
   pypy/dist/pypy/objspace/std/marshal_impl.py
Log:
enable marshalling for multidicts


Modified: pypy/dist/pypy/module/marshal/test/test_marshal.py
==============================================================================
--- pypy/dist/pypy/module/marshal/test/test_marshal.py	(original)
+++ pypy/dist/pypy/module/marshal/test/test_marshal.py	Fri Feb  2 15:25:12 2007
@@ -589,3 +589,11 @@
         x = marshal.load(f)
         assert x == case
 
+
+class AppTestMultiDict(object):
+    def setup_class(cls):
+        from pypy.conftest import gettestobjspace
+        cls.space = gettestobjspace(**{"objspace.std.withmultidict": True})
+
+    test__dict__tcid_ = AppTestMarshal.test__dict__tcid_.im_func
+    test__dict_5_colon__6_comma__7_colon__8_tcid_ = AppTestMarshal.test__dict_5_colon__6_comma__7_colon__8_tcid_.im_func

Modified: pypy/dist/pypy/objspace/std/marshal_impl.py
==============================================================================
--- pypy/dist/pypy/objspace/std/marshal_impl.py	(original)
+++ pypy/dist/pypy/objspace/std/marshal_impl.py	Fri Feb  2 15:25:12 2007
@@ -25,7 +25,8 @@
 from pypy.objspace.std.tupleobject   import W_TupleObject
 from pypy.objspace.std.listobject    import W_ListObject
 from pypy.objspace.std.dictobject    import W_DictObject
-from pypy.objspace.std.dictstrobject    import W_DictStrObject
+from pypy.objspace.std.dictmultiobject    import W_DictMultiObject
+from pypy.objspace.std.dictstrobject import W_DictStrObject
 from pypy.objspace.std.stringobject  import W_StringObject
 from pypy.objspace.std.typeobject    import W_TypeObject
 from pypy.objspace.std.longobject    import W_LongObject
@@ -328,7 +329,7 @@
 
 def unmarshal_Tuple(space, u, tc):
     items_w = u.get_list_w()
-    return W_TupleObject(items_w)
+    return space.newtuple(items_w)
 register(TYPE_TUPLE, unmarshal_Tuple)
 
 def marshal_w__List(space, w_list, m):
@@ -338,10 +339,10 @@
 
 def unmarshal_List(space, u, tc):
     items_w = u.get_list_w()
-    return W_ListObject(items_w)
+    return space.newlist(items_w)
 
 def finish_List(space, items_w, typecode):
-    return W_ListObject(items_w)
+    return space.newlist(items_w)
 register(TYPE_LIST, unmarshal_List)
 
 def marshal_w__Dict(space, w_dict, m):
@@ -351,6 +352,14 @@
         m.put_w_obj(w_value)
     m.atom(TYPE_NULL)
 
+def marshal_w__DictMulti(space, w_dict, m):
+    m.start(TYPE_DICT)
+    for w_tuple in w_dict.implementation.items():
+        w_key, w_value = space.unpacktuple(w_tuple, 2)
+        m.put_w_obj(w_key)
+        m.put_w_obj(w_value)
+    m.atom(TYPE_NULL)
+
 def marshal_w__DictStr(space, w_dict, m):
     m.start(TYPE_DICT)
     if w_dict.content is not None:
@@ -526,7 +535,7 @@
         w_frozen = space.w_False
     else:
         w_frozen = space.w_True
-    w_lis = W_ListObject(items_w)
+    w_lis = space.newlist(items_w)
     return list_to_set(space, w_lis, w_frozen)
 register(TYPE_SET + TYPE_FROZENSET, unmarshal_set_frozenset)
 



More information about the Pypy-commit mailing list