summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-08-28 22:21:18 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-08-28 22:21:18 (GMT)
commit19ef62d5a98111df15400db22d18a3a555f5f1ff (patch)
tree3cf07d9a119484f98bdc4dd1cbe4787bb7c3d224 /Lib/pickle.py
parent12778e314b884be72dba30145aff6ce8d0156344 (diff)
downloadcpython-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/pickle.py')
-rw-r--r--Lib/pickle.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 8be7a8d..d5773e2 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -615,7 +615,11 @@ class Unpickler:
dispatch[NONE] = load_none
def load_int(self):
- self.append(int(self.readline()[:-1]))
+ data = self.readline()
+ try:
+ self.append(int(data))
+ except ValueError:
+ self.append(long(data))
dispatch[INT] = load_int
def load_binint(self):