summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-08-25 01:04:21 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-08-25 01:04:21 (GMT)
commite0a0a6e93729a44240de6bf78bcf052c4b75427d (patch)
tree69e0463708f9d02331739c8a91612561169ef9aa
parentb0d26335f2972731c4ebb5213bd942e2cfbcedbc (diff)
downloadcpython-e0a0a6e93729a44240de6bf78bcf052c4b75427d.zip
cpython-e0a0a6e93729a44240de6bf78bcf052c4b75427d.tar.gz
cpython-e0a0a6e93729a44240de6bf78bcf052c4b75427d.tar.bz2
Since PyUnicode_AsString is a public API, don't just assert, but do
a regular check and return an error if not unicode.
-rw-r--r--Objects/unicodeobject.c5
1 files changed, 4 insertions, 1 deletions
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 @@ 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;