summaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-10-06 17:35:10 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-10-06 20:20:31 -0300
commit9861730eee5a232fb5753cc799dfe3af46bc8286 (patch)
tree31a1343027f92af9765c23dd4920693f27244afe /libshiboken
parent1fbc44dbcdcb67594cd85c9efe956c52bb2f4463 (diff)
downloadshiboken-9861730eee5a232fb5753cc799dfe3af46bc8286.tar.gz
shiboken-9861730eee5a232fb5753cc799dfe3af46bc8286.tar.xz
shiboken-9861730eee5a232fb5753cc799dfe3af46bc8286.zip
Add macros to kept python 2.5 compatibility.
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/python25compat.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/libshiboken/python25compat.h b/libshiboken/python25compat.h
index cbe6b9d2..09353391 100644
--- a/libshiboken/python25compat.h
+++ b/libshiboken/python25compat.h
@@ -22,6 +22,8 @@
#ifndef PYTHON25COMPAT_H
#define PYTHON25COMPAT_H
+#include <Python.h>
+#include <cstring>
/*
*The #defines below were taken from Cython-generated code to allow shiboken to be used with python2.5.
@@ -61,16 +63,21 @@ typedef struct {
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
-#endif
-#if PY_MAJOR_VERSION < 3
-#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
-#else
-#define __Pyx_BUILTIN_MODULE_NAME "builtins"
-#endif
+#define PyBytes_Check PyString_Check
+#define PyBytes_FromString PyString_FromString
+#define PyBytes_FromFormat PyString_FromFormat
+#define PyBytes_FromStringAndSize PyString_FromStringAndSize
+#define PyBytes_GET_SIZE PyString_GET_SIZE
+#define PyBytes_AS_STRING PyString_AS_STRING
+#define PyBytes_AsString PyString_AsString
+#define PyBytes_Concat PyString_Concat
-#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
-#define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
+inline PyObject* PyUnicode_FromString(const char* s)
+{
+ std::size_t len = std::strlen(s);
+ return PyUnicode_DecodeUTF8(s, len, 0);
+}
+#endif
#endif