[Python-checkins] cpython: PyUnicode_CopyCharacters() uses exceptions instead of assertions

victor.stinner python-checkins at python.org
Fri Sep 30 02:26:40 CEST 2011


http://hg.python.org/cpython/rev/5d49d11f912d
changeset:   72545:5d49d11f912d
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Fri Sep 30 02:26:10 2011 +0200
summary:
  PyUnicode_CopyCharacters() uses exceptions instead of assertions

Call PyErr_BadInternalCall() if inputs are not unicode strings.

files:
  Objects/unicodeobject.c |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -626,8 +626,10 @@
     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;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list