From 32db55336b7061b6735b757c60ad8201fe43b616 Mon Sep 17 00:00:00 2001 From: montag451 Date: Sat, 30 Mar 2013 21:01:41 +0100 Subject: [PATCH] Now it really compiles with Python < 2.6 --- pytun.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pytun.c b/pytun.c index e4f0f01..6467a7c 100644 --- a/pytun.c +++ b/pytun.c @@ -470,7 +470,11 @@ static PyObject* pytun_tuntap_get_mtu(PyObject* self, void* d) return NULL; } +#if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(req.ifr_mtu); +#else + return PyInt_FromLong(req.ifr_mtu); +#endif } static int pytun_tuntap_set_mtu(PyObject* self, PyObject* value, void* d) @@ -658,7 +662,11 @@ static PyObject* pytun_tuntap_write(PyObject* self, PyObject* args) return NULL; } +#if PY_MAJOR_VERSION >= 3 return PyLong_FromSsize_t(written); +#else + return PyInt_FromSsize_t(written); +#endif } PyDoc_STRVAR(pytun_tuntap_write_doc, @@ -666,7 +674,11 @@ PyDoc_STRVAR(pytun_tuntap_write_doc, static PyObject* pytun_tuntap_fileno(PyObject* self) { +#if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(((pytun_tuntap_t*)self)->fd); +#else + return PyInt_FromLong(((pytun_tuntap_t*)self)->fd); +#endif } PyDoc_STRVAR(pytun_tuntap_fileno_doc,