diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-13 11:07:24 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-13 11:07:24 +0000 |
commit | 0705610b3423055e51636d2ac3c476eaf74315e5 (patch) | |
tree | 866c1599d9e9839f003c4f2cfec5860df3c2385a /Lib/pickle.py | |
parent | 45cbf940131b71831f66b5f7eb4e9a30fd98e98f (diff) | |
download | cpython-0705610b3423055e51636d2ac3c476eaf74315e5.tar.gz |
Issue #8383: pickle and pickletools use surrogatepass error handler when
encoding unicode as utf8 to support lone surrogates and stay compatible with
Python 2.x and 3.0
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r-- | Lib/pickle.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index 8a2abcc138..c4fc2c4d1f 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -499,7 +499,7 @@ class _Pickler: def save_str(self, obj, pack=struct.pack): if self.bin: - encoded = obj.encode('utf-8') + encoded = obj.encode('utf-8', 'surrogatepass') n = len(encoded) self.write(BINUNICODE + pack("<i", n) + encoded) else: @@ -966,7 +966,7 @@ class _Unpickler: def load_binunicode(self): len = mloads(b'i' + self.read(4)) - self.append(str(self.read(len), 'utf-8')) + self.append(str(self.read(len), 'utf-8', 'surrogatepass')) dispatch[BINUNICODE[0]] = load_binunicode def load_short_binstring(self): |