Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r70077:e9a9d862dd67 Date: 2014-03-19 00:24 -0400 http://bitbucket.org/pypy/pypy/changeset/e9a9d862dd67/
Log: fix test_marshal 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 @@ -7,7 +7,7 @@ Py_MARSHAL_VERSION = 2 -@unwrap_spec(w_version = WrappedDefault(Py_MARSHAL_VERSION)) +@unwrap_spec(w_version=WrappedDefault(Py_MARSHAL_VERSION)) def dump(space, w_data, w_f, w_version): """Write the 'data' object into the open file 'f'.""" # special case real files for performance @@ -24,7 +24,7 @@ finally: writer.finished() -@unwrap_spec(w_version = WrappedDefault(Py_MARSHAL_VERSION)) +@unwrap_spec(w_version=WrappedDefault(Py_MARSHAL_VERSION)) def dumps(space, w_data, w_version): """Return the string that would have been written to a file by dump(data, file).""" @@ -217,6 +217,16 @@ self.space.marshal_w(w_obj, self) def dump_w_obj(self, w_obj): + space = self.space + if space.type(w_obj).is_heaptype(): + try: + buf = space.buffer_w(w_obj) + except OperationError as e: + if not e.match(space, space.w_TypeError): + raise + self.raise_exc("unmarshallable object") + else: + w_obj = space.newbuffer(buf) 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 @@ -173,10 +173,13 @@ import marshal types = (float, complex, int, long, tuple, list, dict, set, frozenset) for cls in types: + print cls class subtype(cls): pass exc = raises(ValueError, marshal.dumps, subtype) assert str(exc.value) == 'unmarshallable object' + exc = raises(ValueError, marshal.dumps, subtype()) + assert str(exc.value) == 'unmarshallable object' def test_valid_subtypes(self): import marshal _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit