Fix conversation of Python 3 str -> wxString
Conversation of a NoneType for example failed before
This commit is contained in:
parent
22e5e52598
commit
f316b98f45
|
@ -81,6 +81,11 @@ wxString* newWxStringFromPy( PyObject* src )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
obj = PyObject_Str( src );
|
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;
|
must_unref_obj = true;
|
||||||
|
|
||||||
if( PyErr_Occurred() )
|
if( PyErr_Occurred() )
|
||||||
|
@ -101,7 +106,11 @@ wxString* newWxStringFromPy( PyObject* src )
|
||||||
}
|
}
|
||||||
|
|
||||||
result = new wxString();
|
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 );
|
size_t len = PyUnicode_GET_SIZE( uni_str );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( len )
|
if( len )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue