From: Neal Norwitz Date: Sat, 25 Aug 2007 01:04:21 +0000 (+0000) Subject: Since PyUnicode_AsString is a public API, don't just assert, but do X-Git-Tag: v3.0a1~272 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e0a0a6e93729a44240de6bf78bcf052c4b75427d;p=thirdparty%2FPython%2Fcpython.git Since PyUnicode_AsString is a public API, don't just assert, but do a regular check and return an error if not unicode. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 157ea1cf5b18..e227fc72d276 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1204,7 +1204,10 @@ PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode, 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;