summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-01-20 20:43:58 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-01-20 20:43:58 (GMT)
commit8dd05147d6224f4982ef6b14d904bb600ef33ea3 (patch)
treef65fc6569e9fdb3ef82719d268531676f2b2743d /Lib/pickle.py
parent6dc4396708010c001bc4ac1a95550f806f654408 (diff)
downloadcpython-8dd05147d6224f4982ef6b14d904bb600ef33ea3.zip
cpython-8dd05147d6224f4982ef6b14d904bb600ef33ea3.tar.gz
cpython-8dd05147d6224f4982ef6b14d904bb600ef33ea3.tar.bz2
Issue #4842, patch 1/2: fix pickle in Python 3.x so that pickling with the
'L' opcode always appends an 'L' on output, just as 2.x does. When unpickling, remove the trailing 'L' (if present) before passing the result to PyLong_FromString.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 2947bd4..409d4b2 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -470,7 +470,7 @@ class _Pickler:
else:
self.write(LONG4 + pack("<i", n) + encoded)
return
- self.write(LONG + repr(obj).encode("ascii") + b'\n')
+ self.write(LONG + repr(obj).encode("ascii") + b'L\n')
dispatch[int] = save_long
def save_float(self, obj, pack=struct.pack):
@@ -890,6 +890,8 @@ class _Unpickler:
def load_long(self):
val = self.readline()[:-1].decode("ascii")
+ if val and val[-1] == 'L':
+ val = val[:-1]
self.append(int(val, 0))
dispatch[LONG[0]] = load_long