[Python-checkins] CVS: python/dist/src/Lib/test pickletester.py,1.7,1.8

Tim Peters tim_one@users.sourceforge.net
Tue, 28 Aug 2001 15:21:21 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv15915/Lib/test

Modified Files:
	pickletester.py 
Log Message:
pickle.py, load_int():  Match cPickle's just-repaired ability to unpickle
64-bit INTs on 32-bit boxes (where they become longs).  Also exploit that
int(str) and long(str) will ignore a trailing newline (saves creating a
new string at the Python level).

pickletester.py:  Simulate reading a pickle produced by a 64-bit box.


Index: pickletester.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** pickletester.py	2001/08/17 18:39:24	1.7
--- pickletester.py	2001/08/28 22:21:18	1.8
***************
*** 222,223 ****
--- 222,238 ----
                                       got))
          n = n >> 1
+ 
+     # Fake a pickle from a sizeof(long)==8 box.
+     maxint64 = (1L << 63) - 1
+     data = 'I' + str(maxint64) + '\n.'
+     got = pickle.loads(data)
+     if maxint64 != got:
+         raise TestFailed("maxint64 test failed %r %r" % (maxint64, got))
+     # Try too with a bogus literal.
+     data = 'I' + str(maxint64) + 'JUNK\n.'
+     try:
+         got = pickle.loads(data)
+     except ValueError:
+         pass
+     else:
+         raise TestFailed("should have raised error on bogus INT literal")