[Python-checkins] python/dist/src/Lib/test test_marshal.py, 1.8, 1.9

mwh@users.sourceforge.net mwh at users.sourceforge.net
Fri Jun 3 16:42:01 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14030/Lib/test

Modified Files:
	test_marshal.py 
Log Message:
This is my patch:

[ 1180995 ] binary formats for marshalling floats

Adds 2 new type codes for marshal (binary floats and binary complexes), a 
new marshal version (2), updates MAGIC and fiddles the de-serializing of 
code objects to be less likely to clobber the real reason for failing if
it fails.


Index: test_marshal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_marshal.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- test_marshal.py	11 Jan 2005 03:03:06 -0000	1.8
+++ test_marshal.py	3 Jun 2005 14:41:55 -0000	1.9
@@ -73,20 +73,34 @@
             n /= 123.4567
 
         f = 0.0
-        s = marshal.dumps(f)
+        s = marshal.dumps(f, 2)
         got = marshal.loads(s)
         self.assertEqual(f, got)
+        # and with version <= 1 (floats marshalled differently then)
+        s = marshal.dumps(f, 1)
+        got = marshal.loads(s) 
+        self.assertEqual(f, got)       
 
         n = sys.maxint * 3.7e-250
         while n < small:
             for expected in (-n, n):
                 f = float(expected)
+                
                 s = marshal.dumps(f)
                 got = marshal.loads(s)
                 self.assertEqual(f, got)
+                
+                s = marshal.dumps(f, 1)
+                got = marshal.loads(s)
+                self.assertEqual(f, got)
+                
                 marshal.dump(f, file(test_support.TESTFN, "wb"))
                 got = marshal.load(file(test_support.TESTFN, "rb"))
                 self.assertEqual(f, got)
+                
+                marshal.dump(f, file(test_support.TESTFN, "wb"), 1)
+                got = marshal.load(file(test_support.TESTFN, "rb"))
+                self.assertEqual(f, got)
             n *= 123.4567
         os.unlink(test_support.TESTFN)
 



More information about the Python-checkins mailing list