From af5366c52d6467930e92dbea295fe384d4158cb2 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Sat, 28 Feb 2009 22:16:49 -0500 Subject: 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 --- source/str_util.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source') 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)); } -- cgit v1.2.1