MultibyteCodec_Encode() checks if PyUnicode_AS_UNICODE() failed

This commit is contained in:
Victor Stinner 2011-11-21 02:50:14 +01:00
parent 9e30aa52fd
commit 9a80faba88

View file

@ -574,8 +574,11 @@ MultibyteCodec_Encode(MultibyteCodecObject *self,
} }
} }
data = PyUnicode_AS_UNICODE(arg); data = PyUnicode_AsUnicodeAndSize(arg, &datalen);
datalen = PyUnicode_GET_SIZE(arg); if (data == NULL) {
Py_XDECREF(ucvt);
return NULL;
}
errorcb = internal_error_callback(errors); errorcb = internal_error_callback(errors);
if (errorcb == NULL) { if (errorcb == NULL) {