oremanj/python-netfilterqueue

Incompatable Python3.7

idonerizzari opened this issue · 7 comments

Hi,

multiple errors when building with python3. Either python3 setup.py install or pip3 install NetfilterQueue. Can you guide on how to contribute and build this by compiling with a more recent Cython?

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -c netfilterqueue.c -o build/temp.linux-x86_64-3.7/netfilterqueue.o netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’: netfilterqueue.c:2248:67: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types] __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload)); ^ In file included from netfilterqueue.c:490:0: /usr/include/libnetfilter_queue/libnetfilter_queue.h:119:12: note: expected ‘unsigned char **’ but argument is of type ‘char **’ extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data); ^~~~~~~~~~~~~~~ netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’: netfilterqueue.c:2631:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration] __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error) ^~~~~~~~~~~~~~~~~~~~~~~~~~ PyBytes_FromStringAndSize netfilterqueue.c:2631:15: warning: assignment makes pointer from integer without a cast [-Wint-conversion] __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error) ^ netfilterqueue.c: In function ‘__Pyx__ExceptionSave’: netfilterqueue.c:7520:21: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’? *type = tstate->exc_type; ^~~~~~~~ curexc_type netfilterqueue.c:7521:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’? *value = tstate->exc_value; ^~~~~~~~~ curexc_value netfilterqueue.c:7522:19: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? *tb = tstate->exc_traceback; ^~~~~~~~~~~~~ curexc_traceback netfilterqueue.c: In function ‘__Pyx__ExceptionReset’: netfilterqueue.c:7529:24: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’? tmp_type = tstate->exc_type; ^~~~~~~~ curexc_type netfilterqueue.c:7530:25: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’? tmp_value = tstate->exc_value; ^~~~~~~~~ curexc_value netfilterqueue.c:7531:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? tmp_tb = tstate->exc_traceback; ^~~~~~~~~~~~~ curexc_traceback netfilterqueue.c:7532:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’? tstate->exc_type = type; ^~~~~~~~ curexc_type netfilterqueue.c:7533:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’? tstate->exc_value = value; ^~~~~~~~~ curexc_value netfilterqueue.c:7534:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? tstate->exc_traceback = tb; ^~~~~~~~~~~~~ curexc_traceback netfilterqueue.c: In function ‘__Pyx__GetException’: netfilterqueue.c:7589:24: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’? tmp_type = tstate->exc_type; ^~~~~~~~ curexc_type netfilterqueue.c:7590:25: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’? tmp_value = tstate->exc_value; ^~~~~~~~~ curexc_value netfilterqueue.c:7591:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? tmp_tb = tstate->exc_traceback; ^~~~~~~~~~~~~ curexc_traceback netfilterqueue.c:7592:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’? tstate->exc_type = local_type; ^~~~~~~~ curexc_type netfilterqueue.c:7593:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’? tstate->exc_value = local_value; ^~~~~~~~~ curexc_value netfilterqueue.c:7594:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’? tstate->exc_traceback = local_tb; ^~~~~~~~~~~~~ curexc_traceback error: command 'gcc' failed with exit status 1

Hi,
I also just stumbled upon this problem and found a work around:

  1. Install Cython
  2. Build with python setup.py build_ext --force
  3. Install with python setup.py install

setup.py will actually check if Cython is installed, and, if so, will use it to build the extension. However, due to reasons I do not yet understand, Cython believes that the .c. file that ships with this package was up to date (even though it isn't for Python3.7). Thankfully, by passing --force in the build step one can force Cython to generate a new .c regardless.

Best
Johannes

WGH- commented

I'm having the same problem in Python 3.6, and the workaround does't help. Cython generates the same faulty .c which doesn't compile.

The workaround works on Python 3.9 alpha 0.

This workaround shouldn't be needed anymore; the current .c file supports Pythons up to 3.10.

Can you confirm this? It previously claimed to support Python 3.7 but failed during installation.

I just pushed an update before I closed the issue. Please try it and reopen if you’re still having problems. The new code has not yet been uploaded to PyPI so you will need to clone the git repository and build from source.

Okay, cool, thanks. This is where a "closed by commit X" comment can be very handy (made even easier on GitHub with "Closes N" in a commit message).