@@ -5,7 +5,7 @@ function.
5
5
Copyright: (c) 2011, Kerkhoff Technologies Inc.
6
6
License: MIT; see LICENSE.txt
7
7
"""
8
- VERSION = (0 , 8 , 1 )
8
+ VERSION = (0 , 9 , 0 )
9
9
10
10
# Constants for module users
11
11
COPY_NONE = 0
@@ -24,21 +24,13 @@ DEF SockCopySize = MaxCopySize + SockOverhead
24
24
# Socket queue should hold max number of packets of copysize bytes
25
25
DEF SockRcvSize = DEFAULT_MAX_QUEUELEN * SockCopySize // 2
26
26
27
- cdef extern from " Python.h" :
28
- const char * __FILE__
29
- int __LINE__
30
-
31
27
cdef extern from * :
32
28
"""
33
29
#if PY_MAJOR_VERSION < 3
34
30
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
35
31
#endif
36
32
"""
37
33
38
- import socket
39
- import warnings
40
- cimport cpython.version
41
-
42
34
cdef int global_callback(nfq_q_handle * qh, nfgenmsg * nfmsg,
43
35
nfq_data * nfa, void * data) with gil:
44
36
""" Create a Packet and pass it to appropriate callback."""
@@ -227,11 +219,11 @@ cdef class NetfilterQueue:
227
219
newsiz = nfnl_rcvbufsiz(nfq_nfnlh(self .h), sock_len)
228
220
if newsiz != sock_len * 2 :
229
221
try :
230
- warnings.warn_explicit(
222
+ import warnings
223
+
224
+ warnings.warn(
231
225
" Socket rcvbuf limit is now %d , requested %d ." % (newsiz, sock_len),
232
226
category = RuntimeWarning ,
233
- filename = bytes(__FILE__).decode(" ascii" ),
234
- lineno = __LINE__,
235
227
)
236
228
except : # if warnings are being treated as errors
237
229
self .unbind()
@@ -267,6 +259,8 @@ cdef class NetfilterQueue:
267
259
268
260
def run_socket (self , s ):
269
261
""" Accept packets using socket.recv so that, for example, gevent can monkeypatch it."""
262
+ import socket
263
+
270
264
while True :
271
265
try :
272
266
buf = s.recv(BufferSize)
0 commit comments