Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b153615

Browse files
author
Victor Stinner
committed
PyUnicode_CopyCharacters() uses exceptions instead of assertions
Call PyErr_BadInternalCall() if inputs are not unicode strings.
1 parent 1fe99a2 commit b153615

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Objects/unicodeobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,10 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
626626
unsigned int from_kind, to_kind;
627627
void *from_data, *to_data;
628628

629-
assert(PyUnicode_Check(from));
630-
assert(PyUnicode_Check(to));
629+
if (!PyUnicode_Check(from) || !PyUnicode_Check(to)) {
630+
PyErr_BadInternalCall();
631+
return -1;
632+
}
631633

632634
if (PyUnicode_READY(from))
633635
return -1;

0 commit comments

Comments
 (0)