[Python-3000-checkins] r57441 - python/branches/py3k/Objects/unicodeobject.c

neal.norwitz python-3000-checkins at python.org
Sat Aug 25 03:04:22 CEST 2007


Author: neal.norwitz
Date: Sat Aug 25 03:04:21 2007
New Revision: 57441

Modified:
   python/branches/py3k/Objects/unicodeobject.c
Log:
Since PyUnicode_AsString is a public API, don't just assert, but do
a regular check and return an error if not unicode.


Modified: python/branches/py3k/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k/Objects/unicodeobject.c	(original)
+++ python/branches/py3k/Objects/unicodeobject.c	Sat Aug 25 03:04:21 2007
@@ -1204,7 +1204,10 @@
 char*
 PyUnicode_AsString(PyObject *unicode)
 {
-    assert(PyUnicode_Check(unicode));
+    if (!PyUnicode_Check(unicode)) {
+        PyErr_BadArgument();
+        return NULL;
+    }
     unicode = _PyUnicode_AsDefaultEncodedString(unicode, NULL);
     if (!unicode)
         return NULL;


More information about the Python-3000-checkins mailing list