From b153615008570cffb2e5a782d96c2b79db51ea02 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 30 Sep 2011 02:26:10 +0200 Subject: PyUnicode_CopyCharacters() uses exceptions instead of assertions Call PyErr_BadInternalCall() if inputs are not unicode strings. --- Objects/unicodeobject.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 065b5e7..a02c222 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -626,8 +626,10 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start, unsigned int from_kind, to_kind; void *from_data, *to_data; - assert(PyUnicode_Check(from)); - assert(PyUnicode_Check(to)); + if (!PyUnicode_Check(from) || !PyUnicode_Check(to)) { + PyErr_BadInternalCall(); + return -1; + } if (PyUnicode_READY(from)) return -1; -- cgit v0.12