summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorIan Ward <none@none>2009-02-28 22:16:49 -0500
committerIan Ward <none@none>2009-02-28 22:16:49 -0500
commitaf5366c52d6467930e92dbea295fe384d4158cb2 (patch)
tree4e3eaeb29f6c82b0db001453437e15b30038b647 /source
parentb59b0159edea72a92cd3164a4e44c2882c9a4c28 (diff)
downloadurwid-af5366c52d6467930e92dbea295fe384d4158cb2.tar.gz
fix for str_util.is_wide_character by Andrew Psaltis
--HG-- extra : transplant_source : %93%89Py%F2Z%07%9CM%C1%D2%E2c2%7FA%BB%19I%5E
Diffstat (limited to 'source')
-rw-r--r--source/str_util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/str_util.c b/source/str_util.c
index 4203808..90b665f 100644
--- a/source/str_util.c
+++ b/source/str_util.c
@@ -450,6 +450,13 @@ static int Py_IsWideChar(PyObject *text, int offs)
ustr = PyUnicode_AS_UNICODE(text);
return (Py_GetWidth((long int)ustr[offs]) == 2);
}
+
+ if ( text->ob_type != Py_BuildValue("s","")->ob_type ) {
+
+ PyErr_SetString(PyExc_TypeError,
+ "is_wide_char: Argument \"text\" is not a string.");
+ return -1;
+ }
str = (const unsigned char *)PyString_AsString(text);
str_len = (int) PyString_Size(text);
@@ -477,6 +484,10 @@ static PyObject * is_wide_char(PyObject *self, PyObject *args)
return NULL;
ret = Py_IsWideChar(text, offs);
+
+ if ( ret == -1) // error
+ return NULL;
+
return Py_BuildValue("O", to_bool(ret));
}