summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-30 00:26:10 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-30 00:26:10 (GMT)
commitb153615008570cffb2e5a782d96c2b79db51ea02 (patch)
treed6565431a779955c0c6543060951cd6fcca952f7
parent1fe99a2ea7c0f54b19153fce352be456b2613b94 (diff)
downloadcpython-b153615008570cffb2e5a782d96c2b79db51ea02.zip
cpython-b153615008570cffb2e5a782d96c2b79db51ea02.tar.gz
cpython-b153615008570cffb2e5a782d96c2b79db51ea02.tar.bz2
PyUnicode_CopyCharacters() uses exceptions instead of assertions
Call PyErr_BadInternalCall() if inputs are not unicode strings.
-rw-r--r--Objects/unicodeobject.c6
1 files 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;