File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from ._impl import (
2+ COPY_NONE as COPY_NONE ,
3+ COPY_META as COPY_META ,
4+ COPY_PACKET as COPY_PACKET ,
5+ Packet as Packet ,
6+ NetfilterQueue as NetfilterQueue ,
7+ PROTOCOLS as PROTOCOLS ,
8+ )
9+ from ._version import (
10+ VERSION as VERSION ,
11+ __version__ as __version__ ,
12+ )
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ DEF SockCopySize = MaxCopySize + SockOverhead
2323# Socket queue should hold max number of packets of copysize bytes
2424DEF SockRcvSize = DEFAULT_MAX_QUEUELEN * SockCopySize // 2
2525
26- __package__ = " netfilterqueue"
27-
28- from ._version import __version__, VERSION
29-
3026from cpython.exc cimport PyErr_CheckSignals
3127
28+ cdef extern from " Python.h" :
29+ ctypedef struct PyTypeObject:
30+ const char * tp_name
31+
3232# A negative return value from this callback will stop processing and
3333# make nfq_handle_packet return -1, so we use that as the error flag.
3434cdef int global_callback(nfq_q_handle * qh, nfgenmsg * nfmsg,
@@ -346,6 +346,17 @@ cdef class NetfilterQueue:
346346 else :
347347 nfq_handle_packet(self .h, buf, len (buf))
348348
349+ cdef void _fix_names():
350+ # Avoid ._impl showing up in reprs. This doesn't work on PyPy; there we would
351+ # need to modify the name before PyType_Ready(), but I can't find any way to
352+ # write Cython code that would execute at that time.
353+ cdef PyTypeObject* tp = < PyTypeObject* > Packet
354+ tp.tp_name = " netfilterqueue.Packet"
355+ tp = < PyTypeObject* > NetfilterQueue
356+ tp.tp_name = " netfilterqueue.NetfilterQueue"
357+
358+ _fix_names()
359+
349360PROTOCOLS = {
350361 0 : " HOPOPT" ,
351362 1 : " ICMP" ,
Original file line number Diff line number Diff line change 1010
1111 ext_modules = cythonize (
1212 Extension (
13- "netfilterqueue.__init__ " ,
14- ["netfilterqueue/__init__ .pyx" ],
13+ "netfilterqueue._impl " ,
14+ ["netfilterqueue/_impl .pyx" ],
1515 libraries = ["netfilter_queue" ],
1616 ),
1717 compiler_directives = {"language_level" : "3str" },
2323 # setup_requires below.
2424 setup_requires = ["cython" ]
2525 elif not os .path .exists (
26- os .path .join (os .path .dirname (__file__ ), "netfilterqueue/__init__ .c" )
26+ os .path .join (os .path .dirname (__file__ ), "netfilterqueue/_impl .c" )
2727 ):
2828 sys .stderr .write (
2929 "You must have Cython installed (`pip install cython`) to build this "
3434 sys .exit (1 )
3535 ext_modules = [
3636 Extension (
37- "netfilterqueue.__init__ " ,
38- ["netfilterqueue/__init__ .c" ],
37+ "netfilterqueue._impl " ,
38+ ["netfilterqueue/_impl .c" ],
3939 libraries = ["netfilter_queue" ],
4040 )
4141 ]
You can’t perform that action at this time.
0 commit comments