[pypy-svn] r15064 - pypy/dist/pypy/lib

tismer at codespeak.net tismer at codespeak.net
Mon Jul 25 19:25:43 CEST 2005


Author: tismer
Date: Mon Jul 25 19:25:42 2005
New Revision: 15064

Modified:
   pypy/dist/pypy/lib/marshal.py
Log:
added support for not crashing on subtypes

Modified: pypy/dist/pypy/lib/marshal.py
==============================================================================
--- pypy/dist/pypy/lib/marshal.py	(original)
+++ pypy/dist/pypy/lib/marshal.py	Mon Jul 25 19:25:42 2005
@@ -44,7 +44,16 @@
         self.f = f
 
     def dump(self, x):
-        self.dispatch[type(x)](self, x)
+        try:
+            self.dispatch[type(x)](self, x)
+        except KeyError:
+            for tp in type(x).mro():
+                func = self.dispatch.get(tp)
+                if func:
+                    break
+            else:
+                raise ValueError, "unsupported type for marshal.dump"
+            func(self, x)
 
     def w_long64(self, x):
         self.w_long(x)



More information about the Pypy-commit mailing list