From 341a00311680a440d7f979f06c34c70d86c9367a Mon Sep 17 00:00:00 2001 From: Bohuslav Kabrda Date: Fri, 12 Dec 2014 11:04:40 +0100 Subject: Python3 support in SSSD https://fedorahosted.org/sssd/ticket/2017 --- src/util/sss_python.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/util') 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 +#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), \ -- cgit