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-02-13 18:36:50 +0100
commit9687d7db79e15846de385537a99525d11cae6a15 (patch)
treed8d201e1a95841acd1cd1e8b0b2d92038590b053 /src/util
parentdc13b1aff629b0271eb6b75a9f3bdb43c9767093 (diff)
downloadsssd-9687d7db79e15846de385537a99525d11cae6a15.tar.gz
sssd-9687d7db79e15846de385537a99525d11cae6a15.tar.xz
sssd-9687d7db79e15846de385537a99525d11cae6a15.zip
Python3 support in SSSD
https://fedorahosted.org/sssd/ticket/2017 (cherry picked from commit 341a00311680a440d7f979f06c34c70d86c9367a)
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), \