Skip to content

Commit

Permalink
Now it really compiles with Python < 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
montag451 committed Mar 30, 2013
1 parent 07d7e03 commit 32db553
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pytun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -658,15 +662,23 @@ 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,
"write(str) -> number of bytes written. Write str to device.");

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,
Expand Down

0 comments on commit 32db553

Please sign in to comment.