[pypy-svn] r15065 - in pypy/dist/pypy/lib: . test2

arigo at codespeak.net arigo at codespeak.net
Mon Jul 25 19:29:27 CEST 2005


Author: arigo
Date: Mon Jul 25 19:29:24 2005
New Revision: 15065

Added:
   pypy/dist/pypy/lib/test2/test_marshal_extra.py
      - copied, changed from r15064, pypy/dist/pypy/lib/test2/inprogress_marshal_extra.py
Removed:
   pypy/dist/pypy/lib/test2/inprogress_marshal_extra.py
Modified:
   pypy/dist/pypy/lib/marshal.py
Log:
Completed marshal.


Modified: pypy/dist/pypy/lib/marshal.py
==============================================================================
--- pypy/dist/pypy/lib/marshal.py	(original)
+++ pypy/dist/pypy/lib/marshal.py	Mon Jul 25 19:29:24 2005
@@ -203,10 +203,22 @@
     def dump_set(self, x):
         self.f.write(TYPE_SET)
         self.w_long(len(x))
-        for each in set:
+        for each in x:
             self.dump(each)
-    dispatch[TYPE_SET] = dump_set
-    dispatch[TYPE_FROZENSET] = dump_set
+    try:
+        dispatch[set] = dump_set
+    except NameError:
+        pass
+
+    def dump_frozenset(self, x):
+        self.f.write(TYPE_FROZENSET)
+        self.w_long(len(x))
+        for each in x:
+            self.dump(each)
+    try:
+        dispatch[frozenset] = dump_frozenset
+    except NameError:
+        pass
 
 class NULL:
     pass

Deleted: /pypy/dist/pypy/lib/test2/inprogress_marshal_extra.py
==============================================================================
--- /pypy/dist/pypy/lib/test2/inprogress_marshal_extra.py	Mon Jul 25 19:29:24 2005
+++ (empty file)
@@ -1,82 +0,0 @@
-import sys
-import marshal as cpy_marshal
-from pypy.lib import marshal
-
-hello = "he"
-hello += "llo"
-def func(x):
-    return lambda y: x+y
-scopefunc = func(42)
-
-TESTCASES = [
-    None,
-    False,
-    True,
-    StopIteration,
-    Ellipsis,
-    42,
-    sys.maxint,
-    -1.25,
-    2+5j,
-    42L,
-    -1234567890123456789012345678901234567890L,
-    hello,   # not interned
-    "hello",
-    (),
-    (1, 2),
-    [],
-    [3, 4],
-    {},
-    {5: 6, 7: 8},
-    func.func_code,
-    scopefunc.func_code,
-    u'hello',
-    ]
-
-try:
-    TESTCASES += [
-        set(),
-        set([1, 2]),
-        frozenset(),
-        frozenset([3, 4]),
-        ]
-except NameError:
-    pass    # Python < 2.4
-
-
-def test_cases():
-    for case in TESTCASES:
-        yield dump_and_reload, case
-        yield load_from_cpython, case
-        yield dump_to_cpython, case
-        yield dump_subclass, case
-
-def dump_and_reload(case):
-    print 'dump_and_reload', `case`
-    s = marshal.dumps(case)
-    obj = marshal.loads(s)
-    assert obj == case
-
-def load_from_cpython(case):
-    print 'load_from_cpython', `case`
-    s = cpy_marshal.dumps(case)
-    obj = marshal.loads(s)
-    assert obj == case
-
-def dump_to_cpython(case):
-    print 'dump_to_cpython', `case`
-    s = marshal.dumps(case)
-    obj = cpy_marshal.loads(s)
-    assert obj == case
-
-def dump_subclass(case):
-    try:
-        class Subclass(type(case)):
-            pass
-        case = Subclass(case)
-    except TypeError:
-        return
-    print 'dump_subclass', `case`
-    s = marshal.dumps(case)
-    obj = marshal.loads(s)
-    assert obj == case

Copied: pypy/dist/pypy/lib/test2/test_marshal_extra.py (from r15064, pypy/dist/pypy/lib/test2/inprogress_marshal_extra.py)
==============================================================================
--- pypy/dist/pypy/lib/test2/inprogress_marshal_extra.py	(original)
+++ pypy/dist/pypy/lib/test2/test_marshal_extra.py	Mon Jul 25 19:29:24 2005
@@ -59,12 +59,19 @@
 
 def load_from_cpython(case):
     print 'load_from_cpython', `case`
-    s = cpy_marshal.dumps(case)
+    try:
+        s = cpy_marshal.dumps(case)
+    except ValueError:
+        return   # this version of CPython doesn't support this object
     obj = marshal.loads(s)
     assert obj == case
 
 def dump_to_cpython(case):
     print 'dump_to_cpython', `case`
+    try:
+        cpy_marshal.dumps(case)
+    except ValueError:
+        return   # this version of CPython doesn't support this object
     s = marshal.dumps(case)
     obj = cpy_marshal.loads(s)
     assert obj == case



More information about the Pypy-commit mailing list