diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-10-06 10:54:11 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:18:20 -0300 |
commit | d295b8da7ca28d08a31cc7e9338b57f889e998a1 (patch) | |
tree | fe75519a063f6779192d988ff2745303ad2728f5 /libshiboken | |
parent | 56e713fd3ca68fe2fc615426469fe7a0e209c3ed (diff) |
Fix string.
Diffstat (limited to 'libshiboken')
-rw-r--r-- | libshiboken/sbkstring.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libshiboken/sbkstring.cpp b/libshiboken/sbkstring.cpp index c20c487e7..a16fa3845 100644 --- a/libshiboken/sbkstring.cpp +++ b/libshiboken/sbkstring.cpp @@ -73,28 +73,32 @@ const char* toCString(PyObject* str) if (str == Py_None) return NULL; #if PY_MAJOR_VERSION >= 3 - return _PyUnicode_AsString(str); + if (PyUnicode_Check(str)) + return _PyUnicode_AsString(str); #else - return PyBytes_AS_STRING(str); + if (PyString_Check(str)) + return PyString_AS_STRING(str); #endif + if (PyBytes_Check(str)) + return PyBytes_AsString(str); } bool concat(PyObject** val1, PyObject* val2) { - if (PyUnicode_Check(val1) && PyUnicode_Check(val2)) { + if (PyUnicode_Check(*val1) && PyUnicode_Check(val2)) { PyObject* result = PyUnicode_Concat(*val1, val2); Py_DECREF(*val1); *val1 = result; return true; } - if (PyBytes_Check(val1) && PyBytes_Check(val2)) { + if (PyBytes_Check(*val1) && PyBytes_Check(val2)) { PyBytes_Concat(val1, val2); return true; } #if PY_MAJOR_VERSION < 3 - if (PyString_Check(val1) && PyString_Check(val2)) { + if (PyString_Check(*val1) && PyString_Check(val2)) { PyString_Concat(val1, val2); return true; } |