aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-09-28 17:55:19 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:18:18 -0300
commit6b21c2fa5eeb6a7c7b6533f1c966a47d8ef07e69 (patch)
tree84dd9809a679171e5d2e707941ed37402d74ba6b
parente5e92df4a71ec01cbe849907b7113f0f65eb5163 (diff)
Fixed regressions caused on python2.x.
-rw-r--r--libshiboken/sbkenum.cpp26
-rw-r--r--libshiboken/sbkstring.cpp5
2 files changed, 21 insertions, 10 deletions
diff --git a/libshiboken/sbkenum.cpp b/libshiboken/sbkenum.cpp
index 98fd11e8a..059c41749 100644
--- a/libshiboken/sbkenum.cpp
+++ b/libshiboken/sbkenum.cpp
@@ -91,7 +91,7 @@ static PyObject* SbkEnum_tp_new(PyTypeObject* type, PyObject* args, PyObject* kw
return reinterpret_cast<PyObject*>(self);
}
-static PyObject* enum_int(PyObject *v)
+static PyObject* enum_int(PyObject* v)
{
#ifdef IS_PY3K
return PyLong_FromLong(SBK_ENUM(v)->ob_value);
@@ -100,12 +100,9 @@ static PyObject* enum_int(PyObject *v)
#endif
}
-static PyObject* enum_bool(PyObject* v)
+static int enum_bool(PyObject* v)
{
- if (SBK_ENUM(v)->ob_value)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
+ return (SBK_ENUM(v)->ob_value > 0);
}
static long getNumberValue(PyObject* v)
@@ -173,22 +170,35 @@ static PyNumberMethods enum_as_number = {
/* nb_add */ 0,
/* nb_subtract */ 0,
/* nb_multiply */ 0,
+#ifndef IS_PY3K
+ /* nb_divide */ 0,
+#endif
/* nb_remainder */ 0,
/* nb_divmod */ 0,
/* nb_power */ 0,
/* nb_negative */ 0,
/* nb_positive */ 0,
- /* nb_absolute */ enum_bool,
- /* nb_bool */ 0,
+ /* nb_absolute */ 0,
+ /* nb_bool */ enum_bool,
/* nb_invert */ 0,
/* nb_lshift */ 0,
/* nb_rshift */ 0,
/* nb_and */ 0,
/* nb_xor */ 0,
/* nb_or */ 0,
+#ifndef IS_PY3K
+ /* nb_coerce */ 0,
+#endif
/* nb_int */ enum_int,
+#ifdef IS_PY3K
/* nb_reserved */ 0,
/* nb_float */ 0,
+#else
+ /* nb_long */ enum_int,
+ /* nb_float */ 0,
+ /* nb_oct */ 0,
+ /* nb_hex */ 0,
+#endif
/* nb_inplace_add */ 0,
/* nb_inplace_subtract */ 0,
diff --git a/libshiboken/sbkstring.cpp b/libshiboken/sbkstring.cpp
index 6a23511ac..d9de1a44f 100644
--- a/libshiboken/sbkstring.cpp
+++ b/libshiboken/sbkstring.cpp
@@ -69,7 +69,8 @@ bool concat(PyObject** val1, PyObject* val2)
*val1 = result;
return true;
#else
- return false;
+ PyString_Concat(val1, val2);
+ return true;
#endif
}
@@ -101,7 +102,7 @@ int compare(PyObject* val1, const char* val2)
#if PY_MAJOR_VERSION >= 3
return PyUnicode_CompareWithASCIIString(val1, val2);
#else
- return strcmp(PyString_AS_STRING(X), Y);
+ return strcmp(PyString_AS_STRING(val1), val2);
#endif
}