summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-04-13 11:07:24 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-04-13 11:07:24 (GMT)
commit485fb56eb86a1fcd35fd3d0d37efb5ec514dba2b (patch)
treef6b23e9670e70af104a248010798942acdbc5c7b /Modules
parent36067606707844f7de076cf1846afb767b494d7e (diff)
downloadcpython-485fb56eb86a1fcd35fd3d0d37efb5ec514dba2b.zip
cpython-485fb56eb86a1fcd35fd3d0d37efb5ec514dba2b.tar.gz
cpython-485fb56eb86a1fcd35fd3d0d37efb5ec514dba2b.tar.bz2
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 'Modules')
-rw-r--r--Modules/_pickle.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 29aed7a..0e1c2cd 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1227,7 +1227,9 @@ save_unicode(PicklerObject *self, PyObject *obj)
if (self->bin) {
char pdata[5];
- encoded = PyUnicode_AsUTF8String(obj);
+ encoded = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(obj),
+ PyUnicode_GET_SIZE(obj),
+ "surrogatepass");
if (encoded == NULL)
goto error;
@@ -3352,7 +3354,7 @@ load_binunicode(UnpicklerObject *self)
if (unpickler_read(self, &s, size) < 0)
return -1;
- str = PyUnicode_DecodeUTF8(s, size, NULL);
+ str = PyUnicode_DecodeUTF8(s, size, "surrogatepass");
if (str == NULL)
return -1;