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 157ea1c..e227fc7 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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;