PyUnicode_CopyCharacters() uses exceptions instead of assertions

Call PyErr_BadInternalCall() if inputs are not unicode strings.
This commit is contained in:
Victor Stinner 2011-09-30 02:26:10 +02:00
parent 1fe99a2ea7
commit b153615008

View file

@ -626,8 +626,10 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
unsigned int from_kind, to_kind; unsigned int from_kind, to_kind;
void *from_data, *to_data; void *from_data, *to_data;
assert(PyUnicode_Check(from)); if (!PyUnicode_Check(from) || !PyUnicode_Check(to)) {
assert(PyUnicode_Check(to)); PyErr_BadInternalCall();
return -1;
}
if (PyUnicode_READY(from)) if (PyUnicode_READY(from))
return -1; return -1;