From a0229b21cb5cfc6e263cc2396d5b1e8530d9d38d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Sep 2009 03:14:38 +0000 Subject: text display (debug info) in the game engine working again & other minor changes. --- source/gameengine/Expressions/PyObjectPlus.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/gameengine/Expressions/PyObjectPlus.cpp') diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 99c943d4f24..1d1d9e6103b 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -751,16 +751,17 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt STR_String *var = reinterpret_cast(ptr); if (PyUnicode_Check(value)) { - char *val = _PyUnicode_AsString(value); + Py_ssize_t val_len; + char *val = _PyUnicode_AsStringAndSize(value, &val_len); if (attrdef->m_clamp) { - if (strlen(val) < attrdef->m_imin) + if (val_len < attrdef->m_imin) { // can't increase the length of the string PyErr_Format(PyExc_ValueError, "string length too short for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; } - else if (strlen(val) > attrdef->m_imax) + else if (val_len > attrdef->m_imax) { // trim the string char c = val[attrdef->m_imax]; @@ -769,7 +770,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt val[attrdef->m_imax] = c; break; } - } else if (strlen(val) < attrdef->m_imin || strlen(val) > attrdef->m_imax) + } else if (val_len < attrdef->m_imin || val_len > attrdef->m_imax) { PyErr_Format(PyExc_ValueError, "string length out of range for attribute \"%s\"", attrdef->m_name); goto FREE_AND_ERROR; -- cgit v1.2.3