summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorBohuslav Kabrda <bkabrda@redhat.com>2014-12-12 11:04:40 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-01-13 10:25:37 +0100
commit341a00311680a440d7f979f06c34c70d86c9367a (patch)
tree95fdcbed6ddffb50958174c42157ceecaa06ac66 /src/util
parentfaae3d55e5cf416f16158d3b9f8c8fd475ac6acf (diff)
downloadsssd-341a00311680a440d7f979f06c34c70d86c9367a.tar.gz
sssd-341a00311680a440d7f979f06c34c70d86c9367a.tar.xz
sssd-341a00311680a440d7f979f06c34c70d86c9367a.zip
Python3 support in SSSD
https://fedorahosted.org/sssd/ticket/2017
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sss_python.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/util/sss_python.h b/src/util/sss_python.h
index 8f81bf91b..828bd22ec 100644
--- a/src/util/sss_python.h
+++ b/src/util/sss_python.h
@@ -11,6 +11,20 @@
#define sss_py_const_p(type, value) (value)
#endif
+#if PY_MAJOR_VERSION >= 3
+#define IS_PY3K
+#define MODINITERROR return NULL
+#define PYNUMBER_CHECK(what) PyLong_Check(what)
+#define PYNUMBER_FROMLONG(what) PyLong_FromLong(what)
+#define PYNUMBER_ASLONG(what) PyLong_AsLong(what)
+#else
+#include <bytesobject.h>
+#define MODINITERROR return
+#define PYNUMBER_CHECK(what) PyInt_Check(what)
+#define PYNUMBER_FROMLONG(what) PyInt_FromLong(what)
+#define PYNUMBER_ASLONG(what) PyInt_AsLong(what)
+#endif
+
/* Py_ssize_t compatibility for python < 2.5 as per
* http://www.python.org/dev/peps/pep-0353/ */
#ifndef HAVE_PY_SSIZE_T
@@ -45,7 +59,7 @@ sss_exception_with_doc(char *name, char *doc, PyObject *base, PyObject *dict);
/* Convenience macros */
#define TYPE_READY(module, type, name) do { \
if (PyType_Ready(&type) < 0) \
- return; \
+ MODINITERROR; \
Py_INCREF(&type); \
PyModule_AddObject(module, \
discard_const_p(char, name), \