summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-19 22:19:35 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-19 22:19:35 (GMT)
commitf93254d2992896445cbd1eec0ee4a80eb8edc6b8 (patch)
tree72978d19d4170da77eb68d07ecff3833fb35e349 /Lib/pickle.py
parent00058aa28c8215562995593c57ff9388e2bdb266 (diff)
downloadcpython-f93254d2992896445cbd1eec0ee4a80eb8edc6b8.zip
cpython-f93254d2992896445cbd1eec0ee4a80eb8edc6b8.tar.gz
cpython-f93254d2992896445cbd1eec0ee4a80eb8edc6b8.tar.bz2
Fix test_pickle, by reverting the string opcodes (S, T, U) to returning
strings, in Latin-1. Bytes are once more pickled through bytes.__reduce__, but now it returns "latin-1" as the second parameter. Unfortunately this breaks datetime pickling. I'll have to investigate further; reverting Martin's changes doesn't seem to help.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py20
1 files changed, 3 insertions, 17 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index c158b8d..9570dd4 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -506,20 +506,6 @@ class Pickler:
self.memoize(obj)
dispatch[str8] = save_string
- def save_bytes(self, obj):
- # Like save_string
- if self.bin:
- n = len(obj)
- if n < 256:
- self.write(SHORT_BINSTRING + bytes([n]) + bytes(obj))
- else:
- self.write(BINSTRING + pack("<i", n) + bytes(obj))
- else:
- # Strip leading 'b'
- self.write(STRING + bytes(repr(obj).lstrip("b")) + b'\n')
- self.memoize(obj)
- dispatch[bytes] = save_bytes
-
def save_unicode(self, obj, pack=struct.pack):
if self.bin:
encoded = obj.encode('utf-8')
@@ -945,12 +931,12 @@ class Unpickler:
break
else:
raise ValueError, "insecure string pickle"
- self.append(bytes(codecs.escape_decode(rep)[0]))
+ self.append(str(codecs.escape_decode(rep)[0], "latin-1"))
dispatch[STRING[0]] = load_string
def load_binstring(self):
len = mloads(b'i' + self.read(4))
- self.append(self.read(len))
+ self.append(str(self.read(len), "latin-1"))
dispatch[BINSTRING[0]] = load_binstring
def load_unicode(self):
@@ -964,7 +950,7 @@ class Unpickler:
def load_short_binstring(self):
len = ord(self.read(1))
- self.append(self.read(len))
+ self.append(str(self.read(len), "latin-1"))
dispatch[SHORT_BINSTRING[0]] = load_short_binstring
def load_tuple(self):