mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
PyUnicode_CopyCharacters() uses exceptions instead of assertions
Call PyErr_BadInternalCall() if inputs are not unicode strings.
This commit is contained in:
parent
1fe99a2ea7
commit
b153615008
1 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue