X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae13f2927518be5c7b45d1bdb050fb20fc429672..c1cb24a46088fe648eabf5bf12cda8d2779c734f:/wxPython/src/helpers.cpp diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 0c46c50b7d..c10641926d 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -49,7 +49,7 @@ //---------------------------------------------------------------------- -#if PYTHON_API_VERSION <= 1007 && wxUSE_UNICODE +#if PYTHON_API_VERSION < 1009 && wxUSE_UNICODE #error Python must support Unicode to use wxWindows Unicode #endif @@ -421,10 +421,10 @@ void wxPyApp::_BootstrapApp() goto error; } - // On wxGTK the locale will be changed to match the system settings, but - // Python needs to have LC_NUMERIC set to "C" in order for the floating - // point conversions and such to work right. -#if defined(__WXGTK__) && PYTHON_API_VERSION <= 1012 + // On wxGTK the locale will be changed to match the system settings, + // but Python before 2.4 needs to have LC_NUMERIC set to "C" in order + // for the floating point conversions and such to work right. +#if defined(__WXGTK__) && PY_VERSION_HEX < 0x02040000 setlocale(LC_NUMERIC, "C"); #endif @@ -1385,7 +1385,7 @@ PyObject* wxPyCBInputStream::getMethod(PyObject* py, char* name) { } -size_t wxPyCBInputStream::GetSize() const { +wxFileOffset wxPyCBInputStream::GetLength() const { wxPyCBInputStream* self = (wxPyCBInputStream*)this; // cast off const if (m_seek && m_tell) { wxFileOffset temp = self->OnSysTell(); @@ -1394,7 +1394,7 @@ size_t wxPyCBInputStream::GetSize() const { return ret; } else - return 0; + return wxInvalidOffset; } @@ -1911,12 +1911,18 @@ wxString* wxString_in_helper(PyObject* source) { if (PyString_Check(source)) Py_DECREF(uni); #else - char* tmpPtr; int tmpSize; - if (PyString_AsStringAndSize(source, &tmpPtr, &tmpSize) == -1) { - PyErr_SetString(PyExc_TypeError, "Unable to convert string"); - return NULL; + // Convert to a string object if it isn't already, then to wxString + PyObject* str = source; + if (!PyString_Check(source)) { + str = PyObject_Str(source); + if (PyErr_Occurred()) return NULL; } + char* tmpPtr; int tmpSize; + PyString_AsStringAndSize(str, &tmpPtr, &tmpSize); target = new wxString(tmpPtr, tmpSize); + + if (!PyString_Check(source)) + Py_DECREF(str); #endif // wxUSE_UNICODE return target;