diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-13 11:09:22 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-13 11:09:22 (GMT) |
commit | f7351b40b54b3354c4a8b01d9072b888256fca87 (patch) | |
tree | f52f592075724b0a8719ebbd9a00cd0b8bc3f0ea /Modules/_pickle.c | |
parent | 1bc6f6ea5e2e2f81922174a96ec7ce759ac8dc8c (diff) | |
download | cpython-f7351b40b54b3354c4a8b01d9072b888256fca87.zip cpython-f7351b40b54b3354c4a8b01d9072b888256fca87.tar.gz cpython-f7351b40b54b3354c4a8b01d9072b888256fca87.tar.bz2 |
Merged revisions 80031 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r80031 | victor.stinner | 2010-04-13 13:07:24 +0200 (mar., 13 avril 2010) | 4 lines
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/_pickle.c')
-rw-r--r-- | Modules/_pickle.c | 6 |
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; |