Fix conversation of Python 3 str -> wxString

Conversation of a NoneType for example failed before
This commit is contained in:
Thomas Pointhuber 2018-08-06 12:31:50 +02:00 committed by Maciej Suminski
parent 22e5e52598
commit f316b98f45
1 changed files with 9 additions and 0 deletions

View File

@ -81,6 +81,11 @@ wxString* newWxStringFromPy( PyObject* src )
#endif
{
obj = PyObject_Str( src );
#if PY_MAJOR_VERSION >= 3
uni_str = obj; // in case of Python 3 our string is already correctly encoded
#endif
must_unref_obj = true;
if( PyErr_Occurred() )
@ -101,7 +106,11 @@ wxString* newWxStringFromPy( PyObject* src )
}
result = new wxString();
#if PY_MAJOR_VERSION >= 3
size_t len = PyUnicode_GET_LENGTH( uni_str );
#else
size_t len = PyUnicode_GET_SIZE( uni_str );
#endif
if( len )
{