Author: Brian Kearns <[email protected]>
Branch:
Changeset: r70071:07f40b57d13c
Date: 2014-03-18 20:35 -0400
http://bitbucket.org/pypy/pypy/changeset/07f40b57d13c/
Log: test/fix marshal behavior wrt buffers
diff --git a/pypy/module/marshal/interp_marshal.py
b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -217,11 +217,6 @@
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:
diff --git a/pypy/module/marshal/test/test_marshal.py
b/pypy/module/marshal/test/test_marshal.py
--- a/pypy/module/marshal/test/test_marshal.py
+++ b/pypy/module/marshal/test/test_marshal.py
@@ -2,6 +2,8 @@
class AppTestMarshal:
+ spaceconfig = {'usemodules': ['array']}
+
def setup_class(cls):
tmpfile = udir.join('AppTestMarshal.tmp')
cls.w_tmpfile = cls.space.wrap(str(tmpfile))
@@ -173,7 +175,15 @@
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
@@ -182,7 +192,8 @@
class AppTestSmallLong(AppTestMarshal):
- spaceconfig = {"objspace.std.withsmalllong": True}
+ spaceconfig = AppTestMarshal.spaceconfig.copy()
+ spaceconfig["objspace.std.withsmalllong"] = True
def test_smalllong(self):
import __pypy__
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit