Since PyUnicode_AsString is a public API, don't just assert, but do

a regular check and return an error if not unicode.
This commit is contained in:
Neal Norwitz 2007-08-25 01:04:21 +00:00
parent b0d26335f2
commit e0a0a6e937

View file

@ -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;