From e0a0a6e93729a44240de6bf78bcf052c4b75427d Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Sat, 25 Aug 2007 01:04:21 +0000 Subject: [PATCH] Since PyUnicode_AsString is a public API, don't just assert, but do a regular check and return an error if not unicode. --- Objects/unicodeobject.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 157ea1cf5b..e227fc72d2 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; -- 2.40.0