diff options
author | Slavek Kabrda <bkabrda@redhat.com> | 2015-01-21 12:57:35 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2015-02-03 21:16:25 +0100 |
commit | 5cc3d02060f67317049b6e0549c87a407e030e61 (patch) | |
tree | 15174b46cabd9ea08a1c9c35ebb831018577f00f /src/compat.h | |
parent | 9fa1352cd540aa69dd8b59e56de9b8020563e545 (diff) | |
download | python-dmidecode-5cc3d02060f67317049b6e0549c87a407e030e61.tar.gz python-dmidecode-5cc3d02060f67317049b6e0549c87a407e030e61.tar.xz python-dmidecode-5cc3d02060f67317049b6e0549c87a407e030e61.zip |
Port to Python 3 while maintaining compatibility with Python >= 2.6
Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'src/compat.h')
-rw-r--r-- | src/compat.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/compat.h b/src/compat.h index 80a08c6..170f596 100644 --- a/src/compat.h +++ b/src/compat.h @@ -40,4 +40,19 @@ #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None #endif +// Python 2 vs Python 3 compat +#if PY_MAJOR_VERSION >= 3 +#define IS_PY3K +#define MODINITERROR return NULL +#define PYNUMBER_FROMLONG PyLong_FromLong +#define PYTEXT_FROMSTRING PyUnicode_FromString +#else +#include <bytesobject.h> +#define MODINITERROR return +#define PYNUMBER_FROMLONG PyInt_FromLong +#define PYTEXT_FROMSTRING PyString_FromString +#define PyCapsule_New(pointer, name, destructor) \ + (PyCObject_FromVoidPtr(pointer, destructor)) +#endif + #endif |