From 0705610b3423055e51636d2ac3c476eaf74315e5 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 13 Apr 2010 11:07:24 +0000 Subject: 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 --- Lib/pickle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/pickle.py') 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("