[pypy-commit] pypy py3k: Delicate update for marshal bad data, to better match CPython.
amauryfa
noreply at buildbot.pypy.org
Tue Dec 11 01:04:43 CET 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r59393:562b0f79511a
Date: 2012-12-11 01:03 +0100
http://bitbucket.org/pypy/pypy/changeset/562b0f79511a/
Log: Delicate update for marshal bad data, to better match CPython.
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
@@ -180,6 +180,12 @@
exc = raises(ValueError, marshal.loads, b'\x01')
assert r"'\x01'" in exc.value.message
+ def test_bad_data(self):
+ import marshal
+ # Yes, there is code that depends on this :-(
+ raises(EOFError, marshal.loads, b'<test>')
+ raises(MemoryError, marshal.loads, b'(test)')
+
class AppTestSmallLong(AppTestMarshal):
spaceconfig = {"objspace.std.withsmalllong": True}
diff --git a/pypy/objspace/std/marshal_impl.py b/pypy/objspace/std/marshal_impl.py
--- a/pypy/objspace/std/marshal_impl.py
+++ b/pypy/objspace/std/marshal_impl.py
@@ -423,13 +423,14 @@
handled_by_any.append( ('frozenset', marshal_w_frozenset) )
def unmarshal_set_frozenset(space, u, tc):
- items_w = u.get_tuple_w()
- if tc == TYPE_SET:
- w_frozen = space.w_False
- else:
- w_frozen = space.w_True
- w_tup = space.newtuple(items_w)
- return tuple_to_set(space, w_tup, w_frozen)
+ lng = u.get_lng()
+ w_set = space.call_function(space.w_set)
+ for i in xrange(lng):
+ w_obj = u.get_w_obj()
+ space.call_method(w_set, "add", w_obj)
+ if tc == TYPE_FROZENSET:
+ w_set = space.call_function(space.w_frozenset, w_set)
+ return w_set
register(TYPE_SET + TYPE_FROZENSET, unmarshal_set_frozenset)
# dispatching for all not directly dispatched types
More information about the pypy-commit
mailing list