]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/helpers.cpp
reSWIGged
[wxWidgets.git] / wxPython / src / helpers.cpp
index 0c46c50b7dd28f42d01ea49f9f5eee9e9af714b2..ae0ace5dc59b35e7cc4fbd5244508630e1dab85b 100644 (file)
@@ -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;