Amaury Forgeot d'Arc avatar Amaury Forgeot d'Arc committed 562b0f7

Delicate update for marshal bad data, to better match CPython.

Comments (0)

Files changed (2)


         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}


 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.