Commits

Brian Kearns committed 07f40b5

test/fix marshal behavior wrt buffers

  • Participants
  • Parent commits d88001e

Comments (0)

Files changed (2)

File pypy/module/marshal/interp_marshal.py

         self.space.marshal_w(w_obj, self)
 
     def dump_w_obj(self, w_obj):
-        space = self.space
-        if (space.type(w_obj).is_heaptype() and
-            space.lookup(w_obj, "__buffer__") is None):
-            w_err = space.wrap("only builtins can be marshaled")
-            raise OperationError(space.w_ValueError, w_err)
         try:
             self.put_w_obj(w_obj)
         except rstackovf.StackOverflow:

File pypy/module/marshal/test/test_marshal.py

 
 
 class AppTestMarshal:
+    spaceconfig = {'usemodules': ['array']}
+
     def setup_class(cls):
         tmpfile = udir.join('AppTestMarshal.tmp')
         cls.w_tmpfile = cls.space.wrap(str(tmpfile))
         for cls in types:
             class subtype(cls):
                 pass
-            raises(ValueError, marshal.dumps, subtype)
+            exc = raises(ValueError, marshal.dumps, subtype)
+            assert str(exc.value) == 'unmarshallable object'
+
+    def test_valid_subtypes(self):
+        import marshal
+        from array import array
+        class subtype(array):
+            pass
+        assert marshal.dumps(subtype('c', 'test')) == marshal.dumps(array('c', 'test'))
 
     def test_bad_typecode(self):
         import marshal
 
 
 class AppTestSmallLong(AppTestMarshal):
-    spaceconfig = {"objspace.std.withsmalllong": True}
+    spaceconfig = AppTestMarshal.spaceconfig.copy()
+    spaceconfig["objspace.std.withsmalllong"] = True
 
     def test_smalllong(self):
         import __pypy__