python string conversion

- use _PyUnicode_AsStringAndSize where possible
- use %R for PyErr_Format(...) rather then running repr on the object explicitly 
- use const char
This commit is contained in:
2011-11-03 14:09:18 +00:00
parent d210703bca
commit 665f602f15
14 changed files with 55 additions and 46 deletions

View File

@@ -380,7 +380,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
{
wmOperatorType *ot;
PointerRNA ptr;
char *opname= _PyUnicode_AsString(value);
const char *opname= _PyUnicode_AsString(value);
BPy_StructRNA *pyrna= NULL;
if (opname==NULL) {
@@ -413,7 +413,7 @@ static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
wmOperatorType *ot;
wmOperator *op;
PointerRNA ptr;
char *opname= _PyUnicode_AsString(value);
const char *opname= _PyUnicode_AsString(value);
BPy_StructRNA *pyrna= NULL;
if (opname==NULL) {

View File

@@ -1211,7 +1211,7 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
if (!srna) {
if (PyErr_Occurred()) {
PyObject *msg= PyC_ExceptionBuffer();
char *msg_char= _PyUnicode_AsString(msg);
const char *msg_char= _PyUnicode_AsString(msg);
PyErr_Format(PyExc_TypeError,
"%.200s expected an RNA type derived from PropertyGroup, failed with: %s",
error_prefix, msg_char);