diff --git a/wxPython/src/events.i b/wxPython/src/events.i index 5983169335..35fc30b0cc 100644 --- a/wxPython/src/events.i +++ b/wxPython/src/events.i @@ -407,7 +407,7 @@ public: for (int i=0; iGetWriteBuf(len), len); + target->UngetWriteBuf(); } else { // It is a string, get pointers to it and transform to unicode char* tmpPtr; int tmpSize; @@ -1516,7 +1509,9 @@ wxString Py2wxString(PyObject* source) #if wxUSE_UNICODE if (PyUnicode_Check(source)) { - target = PyUnicode_AS_UNICODE(source); + size_t len = PyUnicode_GET_SIZE(source); + PyUnicode_AsWideChar((PyUnicodeObject*)source, target.GetWriteBuf(len), len); + target.UngetWriteBuf(); } else { // It is a string, get pointers to it and transform to unicode char* tmpPtr; int tmpSize; @@ -1549,7 +1544,7 @@ PyObject* wx2PyString(const wxString& src) { PyObject* str; #if wxUSE_UNICODE - str = PyUnicode_FromUnicode(src.c_str(), src.Len()); + str = PyUnicode_FromWideChar(src.c_str(), src.Len()); #else str = PyString_FromStringAndSize(src.c_str(), src.Len()); #endif @@ -2170,7 +2165,7 @@ PyObject* wxArrayString2PyList_helper(const wxArrayString& arr) { PyObject* list = PyList_New(0); for (size_t i=0; i < arr.GetCount(); i++) { #if wxUSE_UNICODE - PyObject* str = PyUnicode_FromUnicode(arr[i].c_str(), arr[i].Len()); + PyObject* str = PyUnicode_FromWideChar(arr[i].c_str(), arr[i].Len()); #else PyObject* str = PyString_FromStringAndSize(arr[i].c_str(), arr[i].Len()); #endif diff --git a/wxPython/src/misc2.i b/wxPython/src/misc2.i index 0538f510e1..6be1cd9725 100644 --- a/wxPython/src/misc2.i +++ b/wxPython/src/misc2.i @@ -1212,7 +1212,7 @@ public: wxString str; if (self->GetMimeType(&str)) { #if wxUSE_UNICODE - return PyUnicode_FromUnicode(str.c_str(), str.Len()); + return PyUnicode_FromWideChar(str.c_str(), str.Len()); #else return PyString_FromStringAndSize(str.c_str(), str.Len()); #endif @@ -1264,7 +1264,7 @@ public: PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon), wxT("wxIcon"), TRUE)); #if wxUSE_UNICODE - PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len())); + PyTuple_SetItem(tuple, 1, PyUnicode_FromWideChar(iconFile.c_str(), iconFile.Len())); #else PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len())); #endif @@ -1283,7 +1283,7 @@ public: wxString str; if (self->GetDescription(&str)) { #if wxUSE_UNICODE - return PyUnicode_FromUnicode(str.c_str(), str.Len()); + return PyUnicode_FromWideChar(str.c_str(), str.Len()); #else return PyString_FromStringAndSize(str.c_str(), str.Len()); #endif @@ -1300,7 +1300,7 @@ public: wxString str; if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) { #if wxUSE_UNICODE - return PyUnicode_FromUnicode(str.c_str(), str.Len()); + return PyUnicode_FromWideChar(str.c_str(), str.Len()); #else return PyString_FromStringAndSize(str.c_str(), str.Len()); #endif @@ -1317,7 +1317,7 @@ public: wxString str; if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) { #if wxUSE_UNICODE - return PyUnicode_FromUnicode(str.c_str(), str.Len()); + return PyUnicode_FromWideChar(str.c_str(), str.Len()); #else return PyString_FromStringAndSize(str.c_str(), str.Len()); #endif @@ -1696,7 +1696,7 @@ public: // #define ADD_STRING(dict, str) \ // wxString tmp##str(str); \ // PyDict_SetItemString(dict, #str, \ -// PyUnicode_FromUnicode(tmp##str.c_str(), tmp##str.Len())) +// PyUnicode_FromWideChar(tmp##str.c_str(), tmp##str.Len())) // #else // #define ADD_STRING(dict, str) \ // PyDict_SetItemString(d, #str, PyString_FromString(str)) diff --git a/wxPython/src/my_typemaps.i b/wxPython/src/my_typemaps.i index 2c028b5b46..1d04fcaf62 100644 --- a/wxPython/src/my_typemaps.i +++ b/wxPython/src/my_typemaps.i @@ -168,7 +168,7 @@ $function %typemap(python, out) wxString { #if wxUSE_UNICODE - $target = PyUnicode_FromUnicode($source->c_str(), $source->Len()); + $target = PyUnicode_FromWideChar($source->c_str(), $source->Len()); #else $target = PyString_FromStringAndSize($source->c_str(), $source->Len()); #endif @@ -180,7 +180,7 @@ $function %typemap(python, out) wxString* { #if wxUSE_UNICODE - $target = PyUnicode_FromUnicode($source->c_str(), $source->Len()); + $target = PyUnicode_FromWideChar($source->c_str(), $source->Len()); #else $target = PyString_FromStringAndSize($source->c_str(), $source->Len()); #endif @@ -274,11 +274,10 @@ $function PyObject* item = PySequence_GetItem($source, i); #if wxUSE_UNICODE PyObject* str = PyObject_Unicode(item); - $target->Add(PyUnicode_AsUnicode(str)); #else PyObject* str = PyObject_Str(item); - $target->Add(PyString_AsString(str)); #endif + $target->Add(Py2wxString(str)); Py_DECREF(item); Py_DECREF(str); } diff --git a/wxPython/src/utils.i b/wxPython/src/utils.i index 70ba8c96e8..07aa916f60 100644 --- a/wxPython/src/utils.i +++ b/wxPython/src/utils.i @@ -46,7 +46,7 @@ if (ret) { PyTuple_SET_ITEM(ret, 0, PyInt_FromLong(flag)); #if wxUSE_UNICODE - PyTuple_SET_ITEM(ret, 1, PyUnicode_FromUnicode(str.c_str(), str.Len())); + PyTuple_SET_ITEM(ret, 1, PyUnicode_FromWideChar(str.c_str(), str.Len())); #else PyTuple_SET_ITEM(ret, 1, PyString_FromStringAndSize(str.c_str(), str.Len())); #endif diff --git a/wxPython/src/wx.i b/wxPython/src/wx.i index abfb6c8d84..ec1ced419d 100644 --- a/wxPython/src/wx.i +++ b/wxPython/src/wx.i @@ -277,7 +277,7 @@ static wxPyCoreAPI API = { PyDict_SetItemString(d,"wxVERSION_NUMBER", PyInt_FromLong((long)wxVERSION_NUMBER )); #if wxUSE_UNICODE wxString tempStr(wxVERSION_STRING); - PyDict_SetItemString(d,"wxVERSION_STRING", PyUnicode_FromUnicode(tempStr.c_str(), tempStr.Len())); + PyDict_SetItemString(d,"wxVERSION_STRING", PyUnicode_FromWideChar(tempStr.c_str(), tempStr.Len())); #else PyDict_SetItemString(d,"wxVERSION_STRING", PyString_FromString(wxVERSION_STRING)); #endif