mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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.
This commit is contained in:
parent
12778e314b
commit
19ef62d5a9
2 changed files with 20 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue