diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-08-28 22:21:18 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-08-28 22:21:18 (GMT) |
commit | 19ef62d5a98111df15400db22d18a3a555f5f1ff (patch) | |
tree | 3cf07d9a119484f98bdc4dd1cbe4787bb7c3d224 /Lib/test/pickletester.py | |
parent | 12778e314b884be72dba30145aff6ce8d0156344 (diff) | |
download | cpython-19ef62d5a98111df15400db22d18a3a555f5f1ff.zip cpython-19ef62d5a98111df15400db22d18a3a555f5f1ff.tar.gz cpython-19ef62d5a98111df15400db22d18a3a555f5f1ff.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r-- | Lib/test/pickletester.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index fa3fb89..fa3ddf4 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -221,3 +221,18 @@ def dotest(pickle): repr(s), 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") |